diff options
author | Kat Marchán <kzm@sykosomatic.org> | 2015-06-25 21:25:14 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-06-27 07:49:24 +0300 |
commit | 09d1bbeba6c5348c0f0ec54c6383416f21daddd9 (patch) | |
tree | 1edc0d630e49f9d83a54abf0725142686110436d /node_modules/normalize-git-url | |
parent | 4e7db7dab54bf30615caa2e8f3c6b2db6b59c258 (diff) |
normalize-git-url@2.0.0
Fix handling of scp-style resource identifiers.
Diffstat (limited to 'node_modules/normalize-git-url')
-rw-r--r-- | node_modules/normalize-git-url/normalize-git-url.js | 23 | ||||
-rw-r--r-- | node_modules/normalize-git-url/package.json | 37 | ||||
-rw-r--r-- | node_modules/normalize-git-url/test/basic.js | 54 |
3 files changed, 60 insertions, 54 deletions
diff --git a/node_modules/normalize-git-url/normalize-git-url.js b/node_modules/normalize-git-url/normalize-git-url.js index 766203794..859e18b9c 100644 --- a/node_modules/normalize-git-url/normalize-git-url.js +++ b/node_modules/normalize-git-url/normalize-git-url.js @@ -1,4 +1,4 @@ -var url = require("url") +var url = require('url') module.exports = function normalize (u) { var parsed = url.parse(u, true) @@ -9,19 +9,22 @@ module.exports = function normalize (u) { // If the path is like ssh://foo:some/path then it works, but // only if you remove the ssh:// if (parsed.protocol) { - parsed.protocol = parsed.protocol.replace(/^git\+/, "") - - // ssh paths that are scp-style urls don't need the ssh:// - parsed.pathname = parsed.pathname.replace(/^\/?:/, "/") + parsed.protocol = parsed.protocol.replace(/^git\+/, '') } // figure out what we should check out. - var checkout = parsed.hash && parsed.hash.substr(1) || "master" - parsed.hash = "" + var checkout = parsed.hash && parsed.hash.substr(1) || 'master' + parsed.hash = '' + + var returnedUrl + if (parsed.pathname.match(/\/?:/)) { + returnedUrl = u.replace(/^(?:git\+)?ssh:\/\//, '').replace(/#[^#]*$/, '') + } else { + returnedUrl = url.format(parsed) + } - u = url.format(parsed) return { - url : u, - branch : checkout + url: returnedUrl, + branch: checkout } } diff --git a/node_modules/normalize-git-url/package.json b/node_modules/normalize-git-url/package.json index df9820a25..d3871ba7a 100644 --- a/node_modules/normalize-git-url/package.json +++ b/node_modules/normalize-git-url/package.json @@ -1,36 +1,35 @@ { "_args": [ [ - "normalize-git-url@~1.0.1", + "normalize-git-url@~2.0.0", "/Users/rebecca/code/npm" ] ], - "_from": "normalize-git-url@>=1.0.1 <1.1.0", - "_id": "normalize-git-url@1.0.1", + "_from": "normalize-git-url@>=2.0.0 <2.1.0", + "_id": "normalize-git-url@2.0.0", "_inCache": true, "_location": "/normalize-git-url", - "_nodeVersion": "2.0.2", + "_nodeVersion": "2.3.1", "_npmUser": { - "email": "ogd@aoaioxxysz.net", - "name": "othiym23" + "email": "me@re-becca.org", + "name": "iarna" }, - "_npmVersion": "2.10.1", + "_npmVersion": "2.11.3", "_phantomChildren": {}, "_requested": { "name": "normalize-git-url", - "raw": "normalize-git-url@~1.0.1", - "rawSpec": "~1.0.1", + "raw": "normalize-git-url@~2.0.0", + "rawSpec": "~2.0.0", "scope": null, - "spec": ">=1.0.1 <1.1.0", + "spec": ">=2.0.0 <2.1.0", "type": "range" }, "_requiredBy": [ "/" ], - "_resolved": "https://registry.npmjs.org/normalize-git-url/-/normalize-git-url-1.0.1.tgz", - "_shasum": "1b561345d66e3a3bc5513a5ace85f155ca42613e", + "_shasum": "2cf92aeda24dd2bccf076edef83f4feaf925e436", "_shrinkwrap": null, - "_spec": "normalize-git-url@~1.0.1", + "_spec": "normalize-git-url@~2.0.0", "_where": "/Users/rebecca/code/npm", "author": { "email": "ogd@aoaioxxysz.net", @@ -48,10 +47,10 @@ "test": "test" }, "dist": { - "shasum": "1b561345d66e3a3bc5513a5ace85f155ca42613e", - "tarball": "http://registry.npmjs.org/normalize-git-url/-/normalize-git-url-1.0.1.tgz" + "shasum": "2cf92aeda24dd2bccf076edef83f4feaf925e436", + "tarball": "http://registry.npmjs.org/normalize-git-url/-/normalize-git-url-2.0.0.tgz" }, - "gitHead": "d87bf42e845ed664e4a8bab3490052fb44c90433", + "gitHead": "cf9fb245bc25d2a8914b71e8989ec426e7819e00", "homepage": "https://github.com/npm/normalize-git-url", "keywords": [ "git", @@ -66,6 +65,10 @@ { "name": "othiym23", "email": "ogd@aoaioxxysz.net" + }, + { + "name": "iarna", + "email": "me@re-becca.org" } ], "name": "normalize-git-url", @@ -77,5 +80,5 @@ "scripts": { "test": "tap test/*.js" }, - "version": "1.0.1" + "version": "2.0.0" } diff --git a/node_modules/normalize-git-url/test/basic.js b/node_modules/normalize-git-url/test/basic.js index f8f199f65..00ac6d313 100644 --- a/node_modules/normalize-git-url/test/basic.js +++ b/node_modules/normalize-git-url/test/basic.js @@ -1,55 +1,55 @@ -var test = require("tap").test +var test = require('tap').test -var normalize = require("../normalize-git-url.js") +var normalize = require('../normalize-git-url.js') -test("basic normalization tests", function (t) { +test('basic normalization tests', function (t) { t.same( - normalize("git+ssh://user@hostname:project.git#commit-ish"), - { url : "ssh://user@hostname/project.git", branch : "commit-ish" } + normalize('git+ssh://user@hostname:project.git#commit-ish'), + { url: 'user@hostname:project.git', branch: 'commit-ish' } ) t.same( - normalize("git+http://user@hostname/project/blah.git#commit-ish"), - { url : "http://user@hostname/project/blah.git", branch : "commit-ish" } + normalize('git+http://user@hostname/project/blah.git#commit-ish'), + { url: 'http://user@hostname/project/blah.git', branch: 'commit-ish' } ) t.same( - normalize("git+https://user@hostname/project/blah.git#commit-ish"), - { url : "https://user@hostname/project/blah.git", branch : "commit-ish" } + normalize('git+https://user@hostname/project/blah.git#commit-ish'), + { url: 'https://user@hostname/project/blah.git', branch: 'commit-ish' } ) t.same( - normalize("git+ssh://git@github.com:npm/npm.git#v1.0.27"), - { url : "ssh://git@github.com/npm/npm.git", branch : "v1.0.27" } + normalize('git+ssh://git@github.com:npm/npm.git#v1.0.27'), + { url: 'git@github.com:npm/npm.git', branch: 'v1.0.27' } ) t.same( - normalize("git+ssh://git@github.com:org/repo#dev"), - { url : "ssh://git@github.com/org/repo", branch : "dev" } + normalize('git+ssh://git@github.com:org/repo#dev'), + { url: 'git@github.com:org/repo', branch: 'dev' } ) t.same( - normalize("git+ssh://git@github.com/org/repo#dev"), - { url : "ssh://git@github.com/org/repo", branch : "dev" } + normalize('git+ssh://git@github.com/org/repo#dev'), + { url: 'ssh://git@github.com/org/repo', branch: 'dev' } ) t.same( - normalize("git+ssh://foo:22/some/path"), - { url : "ssh://foo:22/some/path", branch : "master" } + normalize('git+ssh://foo:22/some/path'), + { url: 'ssh://foo:22/some/path', branch: 'master' } ) t.same( - normalize("git@github.com:org/repo#dev"), - { url : "git@github.com:org/repo", branch : "dev" } + normalize('git@github.com:org/repo#dev'), + { url: 'git@github.com:org/repo', branch: 'dev' } ) t.same( - normalize("git+https://github.com/KenanY/node-uuid"), - { url : "https://github.com/KenanY/node-uuid", branch : "master" } + normalize('git+https://github.com/KenanY/node-uuid'), + { url: 'https://github.com/KenanY/node-uuid', branch: 'master' } ) t.same( - normalize("git+https://github.com/KenanY/node-uuid#7a018f2d075b03a73409e8356f9b29c9ad4ea2c5"), - { url : "https://github.com/KenanY/node-uuid", branch : "7a018f2d075b03a73409e8356f9b29c9ad4ea2c5" } + normalize('git+https://github.com/KenanY/node-uuid#7a018f2d075b03a73409e8356f9b29c9ad4ea2c5'), + { url: 'https://github.com/KenanY/node-uuid', branch: '7a018f2d075b03a73409e8356f9b29c9ad4ea2c5' } ) t.same( - normalize("git+ssh://git@git.example.com:b/b.git#v1.0.0"), - { url : "ssh://git@git.example.com/b/b.git", branch : "v1.0.0" } + normalize('git+ssh://git@git.example.com:b/b.git#v1.0.0'), + { url: 'git@git.example.com:b/b.git', branch: 'v1.0.0' } ) t.same( - normalize("git+ssh://git@github.com:npm/npm-proto.git#othiym23/organized"), - { url : "ssh://git@github.com/npm/npm-proto.git", branch : "othiym23/organized" } + normalize('git+ssh://git@github.com:npm/npm-proto.git#othiym23/organized'), + { url: 'git@github.com:npm/npm-proto.git', branch: 'othiym23/organized' } ) t.end() |