Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
url: add '.' '+' and '-' in url protocol
Browse files Browse the repository at this point in the history
- Based on BNF from RFC 1738 section 5.
- Added tests to cover svn+ssh and some other examples
  • Loading branch information
jordansissel authored and bnoordhuis committed Nov 4, 2011
1 parent 5fd012e commit 358f0ce
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/url.js
Expand Up @@ -30,7 +30,7 @@ exports.format = urlFormat;

// define these here so at least they only have to be
// compiled once on the first module load.
var protocolPattern = /^([a-z0-9+]+:)/i,
var protocolPattern = /^([a-z0-9.+-]+:)/i,
portPattern = /:[0-9]+$/,
// RFC 2396: characters reserved for delimiting URLs.
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
Expand Down
76 changes: 76 additions & 0 deletions test/simple/test-url.js
Expand Up @@ -333,6 +333,49 @@ var parseTests = {
'hash' : '#bar',
'path': '/path?search=foo'
},
'svn+ssh://foo/bar': {
'href': 'svn+ssh://foo/bar',
'host': 'foo',
'hostname': 'foo',
'protocol': 'svn+ssh:',
'pathname': '/bar',
'path': '/bar',
'slashes': true
},
'dash-test://foo/bar': {
'href': 'dash-test://foo/bar',
'host': 'foo',
'hostname': 'foo',
'protocol': 'dash-test:',
'pathname': '/bar',
'path': '/bar',
'slashes': true
},
'dash-test:foo/bar': {
'href': 'dash-test:foo/bar',
'host': 'foo',
'hostname': 'foo',
'protocol': 'dash-test:',
'pathname': '/bar',
'path': '/bar'
},
'dot.test://foo/bar': {
'href': 'dot.test://foo/bar',
'host': 'foo',
'hostname': 'foo',
'protocol': 'dot.test:',
'pathname': '/bar',
'path': '/bar',
'slashes': true
},
'dot.test:foo/bar': {
'href': 'dot.test:foo/bar',
'host': 'foo',
'hostname': 'foo',
'protocol': 'dot.test:',
'pathname': '/bar',
'path': '/bar'
},
// IDNA tests
'http://www.日本語.com/' : {
'href': 'http://www.xn--wgv71a119e.com/',
Expand Down Expand Up @@ -574,6 +617,39 @@ var formatTests = {
'hostname': 'foo',
'protocol': 'http:',
'pathname': '/'
},
'svn+ssh://foo/bar': {
'href': 'svn+ssh://foo/bar',
'hostname': 'foo',
'protocol': 'svn+ssh:',
'pathname': '/bar',
'slashes': true
},
'dash-test://foo/bar': {
'href': 'dash-test://foo/bar',
'hostname': 'foo',
'protocol': 'dash-test:',
'pathname': '/bar',
'slashes': true
},
'dash-test:foo/bar': {
'href': 'dash-test:foo/bar',
'hostname': 'foo',
'protocol': 'dash-test:',
'pathname': '/bar'
},
'dot.test://foo/bar': {
'href': 'dot.test://foo/bar',
'hostname': 'foo',
'protocol': 'dot.test:',
'pathname': '/bar',
'slashes': true
},
'dot.test:foo/bar': {
'href': 'dot.test:foo/bar',
'hostname': 'foo',
'protocol': 'dot.test:',
'pathname': '/bar'
}
};
for (var u in formatTests) {
Expand Down

0 comments on commit 358f0ce

Please sign in to comment.