summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Lucas <evanlucas@me.com>2015-01-12 00:13:17 -0600
committerJulien Gilli <julien.gilli@joyent.com>2015-01-23 13:47:58 -0800
commitde5f24a084795439c10d943afc65bc8d864c607d (patch)
tree1f71027729a0ef97279d9f82d4ac9bf1bf277ed6
parentf34757398fcc393685b4dfbcbdc692fb38332d6c (diff)
downloadnode-de5f24a084795439c10d943afc65bc8d864c607d.tar.gz
url: fix parsing of ssh urls
Fix regression introduced in 61204720361824881aefd64f5bccda7d7be6617a that broke parsing of some ssh: urls. An example url is ssh://git@github.com:npm/npm.git Fixes #9072. Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Julien Gilli <julien.gilli@joyent.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
-rw-r--r--lib/url.js5
-rw-r--r--test/simple/test-url.js16
2 files changed, 18 insertions, 3 deletions
diff --git a/lib/url.js b/lib/url.js
index ac82d2511..6c9aba3f3 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -70,9 +70,8 @@ var protocolPattern = /^([a-z0-9.+-]+:)/i,
nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
hostEndingChars = ['/', '?', '#'],
hostnameMaxLen = 255,
- hostnamePatternString = '[^' + nonHostChars.join('') + ']{0,63}',
- hostnamePartPattern = new RegExp('^' + hostnamePatternString + '$'),
- hostnamePartStart = new RegExp('^(' + hostnamePatternString + ')(.*)$'),
+ hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
+ hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
// protocols that can allow "unsafe" and "unwise" chars.
unsafeProtocol = {
'javascript': true,
diff --git a/test/simple/test-url.js b/test/simple/test-url.js
index f12a00dbe..9eaaf0353 100644
--- a/test/simple/test-url.js
+++ b/test/simple/test-url.js
@@ -857,6 +857,22 @@ var parseTests = {
pathname: '%0D%0Ad/e',
path: '%0D%0Ad/e?f',
href: 'http://a%0D%22%20%09%0A%3C\'b:b@c/%0D%0Ad/e?f'
+ },
+
+ // git urls used by npm
+ 'git+ssh://git@github.com:npm/npm': {
+ protocol: 'git+ssh:',
+ slashes: true,
+ auth: 'git',
+ host: 'github.com',
+ port: null,
+ hostname: 'github.com',
+ hash: null,
+ search: null,
+ query: null,
+ pathname: '/:npm/npm',
+ path: '/:npm/npm',
+ href: 'git+ssh://git@github.com/:npm/npm'
}
};