summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/normalize-git-url/normalize-git-url.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/normalize-git-url/normalize-git-url.js')
-rw-r--r--deps/npm/node_modules/normalize-git-url/normalize-git-url.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/deps/npm/node_modules/normalize-git-url/normalize-git-url.js b/deps/npm/node_modules/normalize-git-url/normalize-git-url.js
index 859e18b9ce..db0022ac36 100644
--- a/deps/npm/node_modules/normalize-git-url/normalize-git-url.js
+++ b/deps/npm/node_modules/normalize-git-url/normalize-git-url.js
@@ -1,7 +1,10 @@
var url = require('url')
module.exports = function normalize (u) {
- var parsed = url.parse(u, true)
+ var parsed = url.parse(u)
+ // If parsing actually alters the URL, it is almost certainly an
+ // scp-style URL, or an invalid one.
+ var altered = u !== url.format(parsed)
// git is so tricky!
// if the path is like ssh://foo:22/some/path then it works, but
@@ -17,8 +20,13 @@ module.exports = function normalize (u) {
parsed.hash = ''
var returnedUrl
- if (parsed.pathname.match(/\/?:/)) {
- returnedUrl = u.replace(/^(?:git\+)?ssh:\/\//, '').replace(/#[^#]*$/, '')
+ if (altered) {
+ if (u.match(/^git\+https?/) && parsed.pathname.match(/\/?:[^0-9]/)) {
+ returnedUrl = u.replace(/^git\+(.*:[^:]+):(.*)/, '$1/$2')
+ } else {
+ returnedUrl = u.replace(/^(?:git\+)?ssh:\/\//, '')
+ }
+ returnedUrl = returnedUrl.replace(/#[^#]*$/, '')
} else {
returnedUrl = url.format(parsed)
}