Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2015-04-10 06:24:49 +0300
committerForrest L Norvell <forrest@npmjs.com>2015-04-10 06:24:49 +0300
commit33d1420bf2f629332fceb2ac7e174e63ac48f96a (patch)
treeff08f37fb621c835e07d2437fd0e24c82ba080e6 /node_modules/hosted-git-info
parent28ce62e3c2f887162c7fd36bd417b46033148980 (diff)
hosted-git-info@2.1.0
Add support for auth embedded directly in Git URLs.
Diffstat (limited to 'node_modules/hosted-git-info')
-rw-r--r--node_modules/hosted-git-info/README.md~99
-rw-r--r--node_modules/hosted-git-info/git-host-info.js64
-rw-r--r--node_modules/hosted-git-info/git-host.js96
-rw-r--r--node_modules/hosted-git-info/index.js220
-rw-r--r--node_modules/hosted-git-info/package.json16
-rw-r--r--node_modules/hosted-git-info/test/https-with-inline-auth.js39
6 files changed, 249 insertions, 285 deletions
diff --git a/node_modules/hosted-git-info/README.md~ b/node_modules/hosted-git-info/README.md~
deleted file mode 100644
index 82ddf605d..000000000
--- a/node_modules/hosted-git-info/README.md~
+++ /dev/null
@@ -1,99 +0,0 @@
-# hosted-git-info
-
-This will let you identify and transform various git hosts URLs between
-protocols. It also can tell you what the URL is for the raw path for
-particular file for direct access without git.
-
-## Usage
-
-```javascript
-var hostedGitInfo = require("hosted-git-info")
-var info = hostedGitInfo.fromUrl("git@github.com:npm/hosted-git-info.git")
-/* info looks like:
-{
- type: "github",
- domain: "github.com",
- user: "npm",
- project: "hosted-git-info"
-}
-*/
-```
-
-If the URL can't be matched with a git host, `null` will be returned. We
-can match git, ssh and https urls. Additionally, we can match ssh connect
-strings (`git@github.com:npm/hosted-git-info`) and shortcuts (eg,
-`github:npm/hosted-git-info`). Github specifically, is detected in the case
-of a third, unprefixed, form: `npm/hosted-git-info`.
-
-If it does match, the returned object has properties of:
-
-* info.type -- The short name of the service
-* info.domain -- The domain for git protocol use
-* info.user -- The name of the user/org on the git host
-* info.project -- The name of the project on the git host
-
-And methods of:
-
-* info.file(path)
-
-Given the path of a file relative to the repository, returns a URL for
-directly fetching it from the githost. If no comittish was set then
-`master` will be used as the default.
-
-For example `hostedGitInfo.fromUrl("git@github.com:npm/hosted-git-info.git#v1.0.0").file("package.json")`
-would return `https://raw.githubusercontent.com/npm/hosted-git-info/v1.0.0/package.json`
-
-* info.shortcut()
-
-eg, `github:npm/hosted-git-info`
-
-* info.browse()
-
-eg, `https://github.com/npm/hosted-git-info/tree/v1.2.0`
-
-* info.bugs()
-
-eg, `https://github.com/npm/hosted-git-info/issues`
-
-* info.docs()
-
-eg, `https://github.com/npm/hosted-git-info/tree/v1.2.0#readme`
-
-* info.https()
-
-eg, `https://github.com/npm/hosted-git-info.git`
-
-* info.sshurl()
-
-eg, `git+ssh://git@github.com/npm/hosted-git-info.git`
-
-* info.ssh()
-
-eg, `git@github.com:npm/hosted-git-info.git`
-
-* info.path()
-
-eg, `npm/hosted-git-info`
-
-* info.getDefaultRepresentation()
-
-Returns the default output type. The default output type is based on the
-string you passed in to be parsed
-
-* info.toString()
-
-Uses the getDefaultRepresentation to call one of the other methods to get a URL for
-this resource. As such `hostedGitInfo.fromUrl(url).toString()` will give
-you a normalized version of the URL that still uses the same protocol.
-
-Shortcuts will still be returned as shortcuts, but the special case github
-form of `org/project` will be normalized to `github:org/project`.
-
-SSH connect strings will be normalized into `git+ssh` URLs.
-
-
-## Supported hosts
-
-Currently this supports Github, Bitbucket and Gitlab. Pull requests for
-additional hosts welcome.
-
diff --git a/node_modules/hosted-git-info/git-host-info.js b/node_modules/hosted-git-info/git-host-info.js
new file mode 100644
index 000000000..354d9fc0d
--- /dev/null
+++ b/node_modules/hosted-git-info/git-host-info.js
@@ -0,0 +1,64 @@
+'use strict'
+
+var gitHosts = module.exports = {
+ github: {
+ // First two are insecure and generally shouldn't be used any more, but
+ // they are still supported.
+ 'protocols': [ 'git', 'http', 'git+ssh', 'git+https', 'ssh', 'https' ],
+ 'domain': 'github.com',
+ 'treepath': 'tree',
+ 'filetemplate': 'https://{auth@}raw.githubusercontent.com/{user}/{project}/{comittish}/{path}',
+ 'bugstemplate': 'https://{domain}/{user}/{project}/issues',
+ 'gittemplate': 'git://{auth@}{domain}/{user}/{project}.git{#comittish}'
+ },
+ bitbucket: {
+ 'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
+ 'domain': 'bitbucket.org',
+ 'treepath': 'src'
+ },
+ gitlab: {
+ 'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
+ 'domain': 'gitlab.com',
+ 'treepath': 'tree',
+ 'docstemplate': 'https://{domain}/{user}/{project}{/tree/comittish}#README',
+ 'bugstemplate': 'https://{domain}/{user}/{project}/issues'
+ },
+ gist: {
+ 'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ],
+ 'domain': 'gist.github.com',
+ 'pathmatch': /^[/](?:([^/]+)[/])?([a-z0-9]+)(?:[.]git)?$/,
+ 'filetemplate': 'https://gist.githubusercontent.com/{user}/{project}/raw{/comittish}/{path}',
+ 'bugstemplate': 'https://{domain}/{project}',
+ 'gittemplate': 'git://{domain}/{project}.git{#comittish}',
+ 'sshtemplate': 'git@{domain}:/{project}.git{#comittish}',
+ 'sshurltemplate': 'git+ssh://git@{domain}/{project}.git{#comittish}',
+ 'browsetemplate': 'https://{domain}/{project}{/comittish}',
+ 'docstemplate': 'https://{domain}/{project}{/comittish}',
+ 'httpstemplate': 'git+https://{domain}/{project}.git{#comittish}',
+ 'shortcuttemplate': '{type}:{project}{#comittish}',
+ 'pathtemplate': '{project}{#comittish}'
+ }
+}
+
+var gitHostDefaults = {
+ 'sshtemplate': 'git@{domain}:{user}/{project}.git{#comittish}',
+ 'sshurltemplate': 'git+ssh://git@{domain}/{user}/{project}.git{#comittish}',
+ 'browsetemplate': 'https://{domain}/{user}/{project}{/tree/comittish}',
+ 'docstemplate': 'https://{domain}/{user}/{project}{/tree/comittish}#readme',
+ 'httpstemplate': 'git+https://{auth@}{domain}/{user}/{project}.git{#comittish}',
+ 'filetemplate': 'https://{domain}/{user}/{project}/raw/{comittish}/{path}',
+ 'shortcuttemplate': '{type}:{user}/{project}{#comittish}',
+ 'pathtemplate': '{user}/{project}{#comittish}',
+ 'pathmatch': /^[/]([^/]+)[/]([^/]+?)(?:[.]git)?$/
+}
+
+Object.keys(gitHosts).forEach(function (name) {
+ Object.keys(gitHostDefaults).forEach(function (key) {
+ if (gitHosts[name][key]) return
+ gitHosts[name][key] = gitHostDefaults[key]
+ })
+ gitHosts[name].protocols_re = RegExp('^(' +
+ gitHosts[name].protocols.map(function (protocol) {
+ return protocol.replace(/([\\+*{}()\[\]$^|])/g, '\\$1')
+ }).join('|') + '):$')
+})
diff --git a/node_modules/hosted-git-info/git-host.js b/node_modules/hosted-git-info/git-host.js
new file mode 100644
index 000000000..b69ad0f28
--- /dev/null
+++ b/node_modules/hosted-git-info/git-host.js
@@ -0,0 +1,96 @@
+'use strict'
+var gitHosts = require('./git-host-info.js')
+
+var GitHost = module.exports = function (type, user, auth, project, comittish, defaultRepresentation) {
+ var gitHostInfo = this
+ gitHostInfo.type = type
+ Object.keys(gitHosts[type]).forEach(function (key) {
+ gitHostInfo[key] = gitHosts[type][key]
+ })
+ gitHostInfo.user = user
+ gitHostInfo.auth = auth
+ gitHostInfo.project = project
+ gitHostInfo.comittish = comittish
+ gitHostInfo.default = defaultRepresentation
+}
+GitHost.prototype = {}
+
+GitHost.prototype.hash = function () {
+ return this.comittish ? '#' + this.comittish : ''
+}
+
+GitHost.prototype._fill = function (template, vars) {
+ if (!template) return
+ if (!vars) vars = {}
+ var self = this
+ Object.keys(this).forEach(function (key) {
+ if (self[key] != null && vars[key] == null) vars[key] = self[key]
+ })
+ var rawAuth = vars.auth
+ var rawComittish = vars.comittish
+ Object.keys(vars).forEach(function (key) {
+ vars[key] = encodeURIComponent(vars[key])
+ })
+ vars['auth@'] = rawAuth ? rawAuth + '@' : ''
+ vars['#comittish'] = rawComittish ? '#' + rawComittish : ''
+ vars['/tree/comittish'] = vars.comittish
+ ? '/' + vars.treepath + '/' + vars.comittish
+ : ''
+ vars['/comittish'] = vars.comittish ? '/' + vars.comittish : ''
+ vars.comittish = vars.comittish || 'master'
+ var res = template
+ Object.keys(vars).forEach(function (key) {
+ res = res.replace(new RegExp('[{]' + key + '[}]', 'g'), vars[key])
+ })
+ return res
+}
+
+GitHost.prototype.ssh = function () {
+ return this._fill(this.sshtemplate)
+}
+
+GitHost.prototype.sshurl = function () {
+ return this._fill(this.sshurltemplate)
+}
+
+GitHost.prototype.browse = function () {
+ return this._fill(this.browsetemplate)
+}
+
+GitHost.prototype.docs = function () {
+ return this._fill(this.docstemplate)
+}
+
+GitHost.prototype.bugs = function () {
+ return this._fill(this.bugstemplate)
+}
+
+GitHost.prototype.https = function () {
+ return this._fill(this.httpstemplate)
+}
+
+GitHost.prototype.git = function () {
+ return this._fill(this.gittemplate)
+}
+
+GitHost.prototype.shortcut = function () {
+ return this._fill(this.shortcuttemplate)
+}
+
+GitHost.prototype.path = function () {
+ return this._fill(this.pathtemplate)
+}
+
+GitHost.prototype.file = function (P) {
+ return this._fill(this.filetemplate, {
+ path: P.replace(/^[/]+/g, '')
+ })
+}
+
+GitHost.prototype.getDefaultRepresentation = function () {
+ return this.default
+}
+
+GitHost.prototype.toString = function () {
+ return (this[this.default] || this.sshurl).call(this)
+}
diff --git a/node_modules/hosted-git-info/index.js b/node_modules/hosted-git-info/index.js
index f15af725c..2c1f66592 100644
--- a/node_modules/hosted-git-info/index.js
+++ b/node_modules/hosted-git-info/index.js
@@ -1,58 +1,61 @@
'use strict'
var url = require('url')
+var gitHosts = require('./git-host-info.js')
+var GitHost = module.exports = require('./git-host.js')
-var GitHost = exports = module.exports = function (type, user, project, comittish, defaultType) {
- var gitHostInfo = this
- gitHostInfo.type = type
- Object.keys(gitHosts[type]).forEach(function (key) {
- gitHostInfo[key] = gitHosts[type][key]
- })
- gitHostInfo.user = user
- gitHostInfo.project = project
- gitHostInfo.comittish = comittish
- gitHostInfo.default = defaultType
-}
-GitHost.prototype = {}
-
-var protocolMap = {
+var protocolToRepresentationMap = {
'git+ssh': 'sshurl',
'git+https': 'https',
'ssh': 'sshurl',
'git': 'git'
}
-function protocolToType (protocol) {
+function protocolToRepresentation (protocol) {
if (protocol.substr(-1) === ':') protocol = protocol.slice(0, -1)
- return protocolMap[protocol] || protocol
+ return protocolToRepresentationMap[protocol] || protocol
}
-exports.fromUrl = function (giturl) {
+var authProtocols = {
+ 'git:': true,
+ 'https:': true,
+ 'http:': true
+}
+
+module.exports.fromUrl = function (giturl) {
if (giturl == null || giturl === '') return
- var parsed = parseGitUrl(maybeGitHubShorthand(giturl) ? 'github:' + giturl : giturl)
- var matches = Object.keys(gitHosts).map(function (V) {
- var gitHost = gitHosts[V]
+ var url = isGitHubShorthand(giturl) ? 'github:' + giturl : giturl
+ var parsed = parseGitUrl(url)
+ var matches = Object.keys(gitHosts).map(function (gitHostName) {
+ var gitHostInfo = gitHosts[gitHostName]
+ var auth = null
+ if (parsed.auth && authProtocols[parsed.protocol]) {
+ auth = decodeURIComponent(parsed.auth)
+ }
var comittish = parsed.hash ? decodeURIComponent(parsed.hash.substr(1)) : null
- if (parsed.protocol === V + ':') {
- return new GitHost(V,
- decodeURIComponent(parsed.host), decodeURIComponent(parsed.path.replace(/^[/](.*?)(?:[.]git)?$/, '$1')), comittish, 'shortcut')
+ var host = null
+ var path = null
+ var defaultRepresentation = null
+ if (parsed.protocol === gitHostName + ':') {
+ host = decodeURIComponent(parsed.host)
+ path = decodeURIComponent(parsed.path.replace(/^[/](.*?)(?:[.]git)?$/, '$1'))
+ defaultRepresentation = 'shortcut'
+ } else {
+ if (parsed.host !== gitHostInfo.domain) return
+ if (!gitHostInfo.protocols_re.test(parsed.protocol)) return
+ var pathmatch = gitHostInfo.pathmatch
+ var matched = parsed.path.match(pathmatch)
+ if (!matched) return
+ if (matched[1] != null) host = decodeURIComponent(matched[1])
+ if (matched[2] != null) path = decodeURIComponent(matched[2])
+ defaultRepresentation = protocolToRepresentation(parsed.protocol)
}
- if (parsed.host !== gitHost.domain) return
- if (!gitHost.protocols_re.test(parsed.protocol)) return
- var pathmatch = gitHost.pathmatch || gitHostDefaults.pathmatch
- var matched = parsed.path.match(pathmatch)
- if (!matched) return
- return new GitHost(
- V,
- matched[1] != null && decodeURIComponent(matched[1]),
- matched[2] != null && decodeURIComponent(matched[2]),
- comittish,
- protocolToType(parsed.protocol))
- }).filter(function (V) { return V })
+ return new GitHost(gitHostName, host, auth, path, comittish, defaultRepresentation)
+ }).filter(function (gitHostInfo) { return gitHostInfo })
if (matches.length !== 1) return
return matches[0]
}
-function maybeGitHubShorthand (arg) {
+function isGitHubShorthand (arg) {
// Note: This does not fully test the git ref format.
// See https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
//
@@ -64,7 +67,7 @@ function maybeGitHubShorthand (arg) {
return /^[^:@%/\s.-][^:@%/\s]*[/][^:@\s/%]+(?:#.*)?$/.test(arg)
}
-var parseGitUrl = function (giturl) {
+function parseGitUrl (giturl) {
if (typeof giturl !== 'string') giturl = '' + giturl
var matched = giturl.match(/^([^@]+)@([^:]+):[/]?((?:[^/]+[/])?[^/]+?)(?:[.]git)?(#.*)?$/)
if (!matched) return url.parse(giturl)
@@ -80,146 +83,7 @@ var parseGitUrl = function (giturl) {
query: null,
pathname: '/' + matched[3],
path: '/' + matched[3],
- href: 'git+ssh://' + matched[1] + '@' + matched[2] + '/' + matched[3] + (matched[4] || '')
+ href: 'git+ssh://' + matched[1] + '@' + matched[2] +
+ '/' + matched[3] + (matched[4] || '')
}
}
-
-var gitHostDefaults = {
- 'sshtemplate': 'git@{domain}:{user}/{project}.git{#comittish}',
- 'sshurltemplate': 'git+ssh://git@{domain}/{user}/{project}.git{#comittish}',
- 'browsetemplate': 'https://{domain}/{user}/{project}{/tree/comittish}',
- 'docstemplate': 'https://{domain}/{user}/{project}{/tree/comittish}#readme',
- 'httpstemplate': 'git+https://{domain}/{user}/{project}.git{#comittish}',
- 'filetemplate': 'https://{domain}/{user}/{project}/raw/{comittish}/{path}',
- 'shortcuttemplate': '{type}:{user}/{project}{#comittish}',
- 'pathtemplate': '{user}/{project}{#comittish}',
- 'pathmatch': /^[/]([^/]+)[/]([^/]+?)(?:[.]git)?$/
-}
-var gitHosts = {
- github: {
- // First two are insecure and generally shouldn't be used any more, but
- // they are still supported.
- 'protocols': [ 'git', 'http', 'git+ssh', 'git+https', 'ssh', 'https' ],
- 'domain': 'github.com',
- 'treepath': 'tree',
- 'filetemplate': 'https://raw.githubusercontent.com/{user}/{project}/{comittish}/{path}',
- 'bugstemplate': 'https://{domain}/{user}/{project}/issues',
- 'gittemplate': 'git://{domain}/{user}/{project}.git{#comittish}'
- },
- bitbucket: {
- 'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
- 'domain': 'bitbucket.org',
- 'treepath': 'src'
- },
- gitlab: {
- 'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
- 'domain': 'gitlab.com',
- 'treepath': 'tree',
- 'docstemplate': 'https://{domain}/{user}/{project}{/tree/comittish}#README',
- 'bugstemplate': 'https://{domain}/{user}/{project}/issues'
- },
- gist: {
- 'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ],
- 'domain': 'gist.github.com',
- 'pathmatch': /^[/](?:([^/]+)[/])?([a-z0-9]+)(?:[.]git)?$/,
- 'filetemplate': 'https://gist.githubusercontent.com/{user}/{project}/raw{/comittish}/{path}',
- 'bugstemplate': 'https://{domain}/{project}',
- 'gittemplate': 'git://{domain}/{project}.git{#comittish}',
- 'sshtemplate': 'git@{domain}:/{project}.git{#comittish}',
- 'sshurltemplate': 'git+ssh://git@{domain}/{project}.git{#comittish}',
- 'browsetemplate': 'https://{domain}/{project}{/comittish}',
- 'docstemplate': 'https://{domain}/{project}{/comittish}',
- 'httpstemplate': 'git+https://{domain}/{project}.git{#comittish}',
- 'shortcuttemplate': '{type}:{project}{#comittish}',
- 'pathtemplate': '{project}{#comittish}'
- }
-}
-
-Object.keys(gitHosts).forEach(function (host) {
- gitHosts[host].protocols_re = RegExp('^(' +
- gitHosts[host].protocols.map(function (P) {
- return P.replace(/([\\+*{}()\[\]$^|])/g, '\\$1')
- }).join('|') + '):$')
-})
-
-GitHost.prototype.hash = function () {
- return this.comittish ? '#' + this.comittish : ''
-}
-
-GitHost.prototype._fill = function (template, vars) {
- if (!template) return
- if (!vars) vars = {}
- var self = this
- Object.keys(this).forEach(function (K) { if (self[K] != null && vars[K] == null) vars[K] = self[K] })
- var rawComittish = vars.comittish
- Object.keys(vars).forEach(function (K) { (K[0] !== '#') && (vars[K] = encodeURIComponent(vars[K])) })
- vars['#comittish'] = rawComittish ? '#' + rawComittish : ''
- vars['/tree/comittish'] = vars.comittish ? '/' + vars.treepath + '/' + vars.comittish : ''
- vars['/comittish'] = vars.comittish ? '/' + vars.comittish : ''
- vars.comittish = vars.comittish || 'master'
- var res = template
- Object.keys(vars).forEach(function (K) {
- res = res.replace(new RegExp('[{]' + K + '[}]', 'g'), vars[K])
- })
- return res
-}
-
-GitHost.prototype.ssh = function () {
- var sshtemplate = this.sshtemplate || gitHostDefaults.sshtemplate
- return this._fill(sshtemplate)
-}
-
-GitHost.prototype.sshurl = function () {
- var sshurltemplate = this.sshurltemplate || gitHostDefaults.sshurltemplate
- return this._fill(sshurltemplate)
-}
-
-GitHost.prototype.browse = function () {
- var browsetemplate = this.browsetemplate || gitHostDefaults.browsetemplate
- return this._fill(browsetemplate)
-}
-
-GitHost.prototype.docs = function () {
- var docstemplate = this.docstemplate || gitHostDefaults.docstemplate
- return this._fill(docstemplate)
-}
-
-GitHost.prototype.bugs = function () {
- var bugstemplate = this.bugstemplate || gitHostDefaults.bugstemplate
- return this._fill(bugstemplate)
-}
-
-GitHost.prototype.https = function () {
- var httpstemplate = this.httpstemplate || gitHostDefaults.httpstemplate
- return this._fill(httpstemplate)
-}
-
-GitHost.prototype.git = function () {
- var gittemplate = this.gittemplate || gitHostDefaults.gittemplate
- return this._fill(gittemplate)
-}
-
-GitHost.prototype.shortcut = function () {
- var shortcuttemplate = this.shortcuttemplate || gitHostDefaults.shortcuttemplate
- return this._fill(shortcuttemplate)
-}
-
-GitHost.prototype.path = function () {
- var pathtemplate = this.pathtemplate || gitHostDefaults.pathtemplate
- return this._fill(pathtemplate)
-}
-
-GitHost.prototype.file = function (P) {
- var filetemplate = this.filetemplate || gitHostDefaults.filetemplate
- return this._fill(filetemplate, {
- path: P.replace(/^[/]+/g, '')
- })
-}
-
-GitHost.prototype.getDefaultRepresentation = function () {
- return this.default
-}
-
-GitHost.prototype.toString = function () {
- return (this[this.default] || this.sshurl).call(this)
-}
diff --git a/node_modules/hosted-git-info/package.json b/node_modules/hosted-git-info/package.json
index c3f7df2a4..e9782903d 100644
--- a/node_modules/hosted-git-info/package.json
+++ b/node_modules/hosted-git-info/package.json
@@ -1,6 +1,6 @@
{
"name": "hosted-git-info",
- "version": "2.0.3",
+ "version": "2.1.0",
"description": "Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab",
"main": "index.js",
"repository": {
@@ -30,10 +30,10 @@
"standard": "^3.3.2",
"tap": "^0.4.13"
},
- "gitHead": "4631ddc33c8aab40bf1ac17165e4e01527a9970b",
- "_id": "hosted-git-info@2.0.3",
- "_shasum": "d58835b6accdfc91ac8fa0707c070cde81f1ddff",
- "_from": "hosted-git-info@2.0.3",
+ "gitHead": "0d2d6a8ae036bc485b32d1c519ae62a95e60ad9b",
+ "_id": "hosted-git-info@2.1.0",
+ "_shasum": "8b38742f56a7e2dafa3eb9ae85eea8b393f4c13e",
+ "_from": "hosted-git-info@>=2.1.0 <2.2.0",
"_npmVersion": "2.7.5",
"_nodeVersion": "1.6.2",
"_npmUser": {
@@ -47,9 +47,9 @@
}
],
"dist": {
- "shasum": "d58835b6accdfc91ac8fa0707c070cde81f1ddff",
- "tarball": "http://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.0.3.tgz"
+ "shasum": "8b38742f56a7e2dafa3eb9ae85eea8b393f4c13e",
+ "tarball": "http://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.1.0.tgz"
},
"directories": {},
- "_resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.0.3.tgz"
+ "_resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.1.0.tgz"
}
diff --git a/node_modules/hosted-git-info/test/https-with-inline-auth.js b/node_modules/hosted-git-info/test/https-with-inline-auth.js
new file mode 100644
index 000000000..5e2f5b5a3
--- /dev/null
+++ b/node_modules/hosted-git-info/test/https-with-inline-auth.js
@@ -0,0 +1,39 @@
+'use strict'
+var HostedGit = require('../index')
+var test = require('tap').test
+
+test('HTTPS GitHub URL with embedded auth -- generally not a good idea', function (t) {
+ function verify (host, label, branch) {
+ var hostinfo = HostedGit.fromUrl(host)
+ var hash = branch ? '#' + branch : ''
+ t.ok(hostinfo, label)
+ if (!hostinfo) return
+ t.is(hostinfo.https(), 'git+https://user:pass@github.com/111/222.git' + hash, label + ' -> https')
+ t.is(hostinfo.git(), 'git://user:pass@github.com/111/222.git' + hash, label + ' -> git')
+ t.is(hostinfo.browse(), 'https://github.com/111/222' + (branch ? '/tree/' + branch : ''), label + ' -> browse')
+ t.is(hostinfo.bugs(), 'https://github.com/111/222/issues', label + ' -> bugs')
+ t.is(hostinfo.docs(), 'https://github.com/111/222' + (branch ? '/tree/' + branch : '') + '#readme', label + ' -> docs')
+ t.is(hostinfo.ssh(), 'git@github.com:111/222.git' + hash, label + ' -> ssh')
+ t.is(hostinfo.sshurl(), 'git+ssh://git@github.com/111/222.git' + hash, label + ' -> sshurl')
+ t.is(hostinfo.shortcut(), 'github:111/222' + hash, label + ' -> shortcut')
+ t.is(hostinfo.file('C'), 'https://user:pass@raw.githubusercontent.com/111/222/' + (branch || 'master') + '/C', label + ' -> file')
+ }
+
+ // insecure protocols
+ verify('git://user:pass@github.com/111/222', 'git')
+ verify('git://user:pass@github.com/111/222.git', 'git.git')
+ verify('git://user:pass@github.com/111/222#branch', 'git#branch', 'branch')
+ verify('git://user:pass@github.com/111/222.git#branch', 'git.git#branch', 'branch')
+
+ verify('https://user:pass@github.com/111/222', 'https')
+ verify('https://user:pass@github.com/111/222.git', 'https.git')
+ verify('https://user:pass@github.com/111/222#branch', 'https#branch', 'branch')
+ verify('https://user:pass@github.com/111/222.git#branch', 'https.git#branch', 'branch')
+
+ verify('http://user:pass@github.com/111/222', 'http')
+ verify('http://user:pass@github.com/111/222.git', 'http.git')
+ verify('http://user:pass@github.com/111/222#branch', 'http#branch', 'branch')
+ verify('http://user:pass@github.com/111/222.git#branch', 'http.git#branch', 'branch')
+
+ t.end()
+})