diff --git a/src/URI.js b/src/URI.js index 757507d..0108995 100644 --- a/src/URI.js +++ b/src/URI.js @@ -526,7 +526,7 @@ if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) { // : may be within the path parts.protocol = undefined; - } else if (string.substring(pos + 1, pos + 3) === '//') { + } else if (string.substring(pos + 1, pos + 3).replace(/\\/g, '/') === '//') { string = string.substring(pos + 3); // extract "user:pass@host:port" diff --git a/test/urls.js b/test/urls.js index 14255c1..c993038 100644 --- a/test/urls.js +++ b/test/urls.js @@ -2082,6 +2082,55 @@ var urls = [{ idn: false, punycode: false } + }, { + name: 'backslashes protocol', + url: 'https:/\\attacker.com', + _url: 'https://attacker.com/', + parts: { + protocol: 'https', + username: null, + password: null, + hostname: 'attacker.com', + port: null, + path: '/', + query: null, + fragment: null + }, + accessors: { + protocol: 'https', + username: '', + password: '', + port: '', + path: '/', + query: '', + fragment: '', + resource: '/', + authority: 'attacker.com', + origin: 'https://attacker.com', + userinfo: '', + subdomain: '', + domain: 'attacker.com', + tld: 'com', + directory: '/', + filename: '', + suffix: '', + hash: '', + search: '', + host: 'attacker.com', + hostname: 'attacker.com' + }, + is: { + urn: false, + url: true, + relative: false, + name: true, + sld: false, + ip: false, + ip4: false, + ip6: false, + idn: false, + punycode: false + } } ];