HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/server/nodejs/v16.9.0/lib/node_modules/npm/node_modules/hosted-git-info/git-host.js
'use strict'
const gitHosts = require('./git-host-info.js')

class GitHost {
  constructor (type, user, auth, project, committish, defaultRepresentation, opts = {}) {
    Object.assign(this, gitHosts[type])
    this.type = type
    this.user = user
    this.auth = auth
    this.project = project
    this.committish = committish
    this.default = defaultRepresentation
    this.opts = opts
  }

  hash () {
    return this.committish ? `#${this.committish}` : ''
  }

  ssh (opts) {
    return this._fill(this.sshtemplate, opts)
  }

  _fill (template, opts) {
    if (typeof template === 'function') {
      const options = { ...this, ...this.opts, ...opts }

      // the path should always be set so we don't end up with 'undefined' in urls
      if (!options.path) {
        options.path = ''
      }

      // template functions will insert the leading slash themselves
      if (options.path.startsWith('/')) {
        options.path = options.path.slice(1)
      }

      if (options.noCommittish) {
        options.committish = null
      }

      const result = template(options)
      return options.noGitPlus && result.startsWith('git+') ? result.slice(4) : result
    }

    return null
  }

  sshurl (opts) {
    return this._fill(this.sshurltemplate, opts)
  }

  browse (path, fragment, opts) {
    // not a string, treat path as opts
    if (typeof path !== 'string') {
      return this._fill(this.browsetemplate, path)
    }

    if (typeof fragment !== 'string') {
      opts = fragment
      fragment = null
    }
    return this._fill(this.browsefiletemplate, { ...opts, fragment, path })
  }

  docs (opts) {
    return this._fill(this.docstemplate, opts)
  }

  bugs (opts) {
    return this._fill(this.bugstemplate, opts)
  }

  https (opts) {
    return this._fill(this.httpstemplate, opts)
  }

  git (opts) {
    return this._fill(this.gittemplate, opts)
  }

  shortcut (opts) {
    return this._fill(this.shortcuttemplate, opts)
  }

  path (opts) {
    return this._fill(this.pathtemplate, opts)
  }

  tarball (opts) {
    return this._fill(this.tarballtemplate, { ...opts, noCommittish: false })
  }

  file (path, opts) {
    return this._fill(this.filetemplate, { ...opts, path })
  }

  getDefaultRepresentation () {
    return this.default
  }

  toString (opts) {
    if (this.default && typeof this[this.default] === 'function') {
      return this[this.default](opts)
    }

    return this.sshurl(opts)
  }
}
module.exports = GitHost