diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-04-11 20:51:42 +0300 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2015-04-11 20:51:42 +0300 |
commit | 66377c6ece2cf4d53d9a618b7d9824e1452bc293 (patch) | |
tree | 112967e82669fb82d83789a011b8999e2a9462e4 /node_modules/hosted-git-info | |
parent | 03cce83b64344a9e0fe036dce214f4d68cfcc9e7 (diff) |
hosted-git-info@2.1.2
`git+https:` and `git+http:` are authed protocols.
Diffstat (limited to 'node_modules/hosted-git-info')
-rw-r--r-- | node_modules/hosted-git-info/index.js | 18 | ||||
-rw-r--r-- | node_modules/hosted-git-info/package.json | 10 | ||||
-rw-r--r-- | node_modules/hosted-git-info/test/bitbucket-https-with-embedded-auth.js | 27 |
3 files changed, 42 insertions, 13 deletions
diff --git a/node_modules/hosted-git-info/index.js b/node_modules/hosted-git-info/index.js index fe510c905..b8c6e10c6 100644 --- a/node_modules/hosted-git-info/index.js +++ b/node_modules/hosted-git-info/index.js @@ -18,7 +18,9 @@ function protocolToRepresentation (protocol) { var authProtocols = { 'git:': true, 'https:': true, - 'http:': true + 'git+https:': true, + 'http:': true, + 'git+http:': true } module.exports.fromUrl = function (giturl) { @@ -34,12 +36,12 @@ module.exports.fromUrl = function (giturl) { auth = decodeURIComponent(parsed.auth) } var comittish = parsed.hash ? decodeURIComponent(parsed.hash.substr(1)) : null - var host = null - var path = null + var user = null + var project = null var defaultRepresentation = null if (parsed.protocol === gitHostName + ':') { - host = decodeURIComponent(parsed.host) - path = decodeURIComponent(parsed.path.replace(/^[/](.*?)(?:[.]git)?$/, '$1')) + user = decodeURIComponent(parsed.host) + project = parsed.path && decodeURIComponent(parsed.path.replace(/^[/](.*?)(?:[.]git)?$/, '$1')) defaultRepresentation = 'shortcut' } else { if (parsed.host !== gitHostInfo.domain) return @@ -47,11 +49,11 @@ module.exports.fromUrl = function (giturl) { 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]) + if (matched[1] != null) user = decodeURIComponent(matched[1]) + if (matched[2] != null) project = decodeURIComponent(matched[2]) defaultRepresentation = protocolToRepresentation(parsed.protocol) } - return new GitHost(gitHostName, host, auth, path, comittish, defaultRepresentation) + return new GitHost(gitHostName, user, auth, project, comittish, defaultRepresentation) }).filter(function (gitHostInfo) { return gitHostInfo }) if (matches.length !== 1) return return matches[0] diff --git a/node_modules/hosted-git-info/package.json b/node_modules/hosted-git-info/package.json index b53862e21..81f477ee6 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.1.1", + "version": "2.1.2", "description": "Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab", "main": "index.js", "repository": { @@ -32,8 +32,8 @@ }, "readme": "# hosted-git-info\n\nThis will let you identify and transform various git hosts URLs between\nprotocols. It also can tell you what the URL is for the raw path for\nparticular file for direct access without git.\n\n## Usage\n\n```javascript\nvar hostedGitInfo = require(\"hosted-git-info\")\nvar info = hostedGitInfo.fromUrl(\"git@github.com:npm/hosted-git-info.git\")\n/* info looks like:\n{\n type: \"github\",\n domain: \"github.com\",\n user: \"npm\",\n project: \"hosted-git-info\"\n}\n*/\n```\n\nIf the URL can't be matched with a git host, `null` will be returned. We\ncan match git, ssh and https urls. Additionally, we can match ssh connect\nstrings (`git@github.com:npm/hosted-git-info`) and shortcuts (eg,\n`github:npm/hosted-git-info`). Github specifically, is detected in the case\nof a third, unprefixed, form: `npm/hosted-git-info`.\n\nIf it does match, the returned object has properties of:\n\n* info.type -- The short name of the service\n* info.domain -- The domain for git protocol use\n* info.user -- The name of the user/org on the git host\n* info.project -- The name of the project on the git host\n\nAnd methods of:\n\n* info.file(path)\n\nGiven the path of a file relative to the repository, returns a URL for\ndirectly fetching it from the githost. If no comittish was set then\n`master` will be used as the default.\n\nFor example `hostedGitInfo.fromUrl(\"git@github.com:npm/hosted-git-info.git#v1.0.0\").file(\"package.json\")`\nwould return `https://raw.githubusercontent.com/npm/hosted-git-info/v1.0.0/package.json`\n\n* info.shortcut()\n\neg, `github:npm/hosted-git-info`\n\n* info.browse()\n\neg, `https://github.com/npm/hosted-git-info/tree/v1.2.0`\n\n* info.bugs()\n\neg, `https://github.com/npm/hosted-git-info/issues`\n\n* info.docs()\n\neg, `https://github.com/npm/hosted-git-info/tree/v1.2.0#readme`\n\n* info.https()\n\neg, `git+https://github.com/npm/hosted-git-info.git`\n\n* info.sshurl()\n\neg, `git+ssh://git@github.com/npm/hosted-git-info.git`\n\n* info.ssh()\n\neg, `git@github.com:npm/hosted-git-info.git`\n\n* info.path()\n\neg, `npm/hosted-git-info`\n\n* info.getDefaultRepresentation()\n\nReturns the default output type. The default output type is based on the\nstring you passed in to be parsed\n\n* info.toString()\n\nUses the getDefaultRepresentation to call one of the other methods to get a URL for\nthis resource. As such `hostedGitInfo.fromUrl(url).toString()` will give\nyou a normalized version of the URL that still uses the same protocol.\n\nShortcuts will still be returned as shortcuts, but the special case github\nform of `org/project` will be normalized to `github:org/project`.\n\nSSH connect strings will be normalized into `git+ssh` URLs.\n\n\n## Supported hosts\n\nCurrently this supports Github, Bitbucket and Gitlab. Pull requests for\nadditional hosts welcome.\n\n", "readmeFilename": "README.md", - "gitHead": "c4d4f14210372ef010cc8170dea84a0dedf504ca", - "_id": "hosted-git-info@2.1.1", - "_shasum": "915946c135ee5ff59437ef126f9bd6112192fcb0", - "_from": "hosted-git-info@>=2.1.1 <2.2.0" + "gitHead": "9f24fee147bb76595e234b7556ecc9d0448215fa", + "_id": "hosted-git-info@2.1.2", + "_shasum": "f947976852931851c33644bbce80d1e499795246", + "_from": "hosted-git-info@>=2.1.2 <2.2.0" } diff --git a/node_modules/hosted-git-info/test/bitbucket-https-with-embedded-auth.js b/node_modules/hosted-git-info/test/bitbucket-https-with-embedded-auth.js new file mode 100644 index 000000000..a2feb2f0e --- /dev/null +++ b/node_modules/hosted-git-info/test/bitbucket-https-with-embedded-auth.js @@ -0,0 +1,27 @@ +'use strict' +var HostedGit = require('../index') +var test = require('tap').test + +test('Bitbucket HTTPS URLs with embedded auth', function (t) { + t.is( + HostedGit.fromUrl('https://user:pass@bitbucket.org/user/repo.git').toString(), + 'git+https://user:pass@bitbucket.org/user/repo.git', + 'credentials were included in URL' + ) + t.is( + HostedGit.fromUrl('https://user:pass@bitbucket.org/user/repo').toString(), + 'git+https://user:pass@bitbucket.org/user/repo.git', + 'credentials were included in URL' + ) + t.is( + HostedGit.fromUrl('git+https://user:pass@bitbucket.org/user/repo.git').toString(), + 'git+https://user:pass@bitbucket.org/user/repo.git', + 'credentials were included in URL' + ) + t.is( + HostedGit.fromUrl('git+https://user:pass@bitbucket.org/user/repo').toString(), + 'git+https://user:pass@bitbucket.org/user/repo.git', + 'credentials were included in URL' + ) + t.end() +}) |