Skip to content

Commit

Permalink
url: fix parsing of ssh urls
Browse files Browse the repository at this point in the history
Fix regression introduced in 6120472
that broke parsing of some ssh: urls.

An example url is ssh://git@github.com:npm/npm.git

PR-URL: #299
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
evanlucas authored and bnoordhuis committed Jan 12, 2015
1 parent 70c2501 commit a1e54d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,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,
Expand Down
16 changes: 16 additions & 0 deletions test/parallel/test-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

};
Expand Down

0 comments on commit a1e54d6

Please sign in to comment.