Skip to content

Commit 6ea641c

Browse files
r0hanSHrodneyrehm
authored andcommitted
fix(parse): case insensitive scheme - #412
1 parent 19e54c7 commit 6ea641c

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

src/URI.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@
513513
}
514514

515515
// slashes and backslashes have lost all meaning for the web protocols (https, http, wss, ws)
516-
string = string.replace(/^(https?|ftp|wss?)?:[/\\]*/, '$1://');
516+
string = string.replace(/^(https?|ftp|wss?)?:[/\\]*/i, '$1://');
517517

518518
// extract protocol
519519
if (string.substring(0, 2) === '//') {

src/URI.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/urls.js

+49
Original file line numberDiff line numberDiff line change
@@ -2327,6 +2327,55 @@ var urls = [{
23272327
idn: false,
23282328
punycode: false
23292329
}
2330+
}, {
2331+
name: 'excessive slash protocol https case-insensitive',
2332+
url: 'hTTps://////attacker.com',
2333+
_url: 'hTTps://attacker.com/',
2334+
parts: {
2335+
protocol: 'hTTps',
2336+
username: null,
2337+
password: null,
2338+
hostname: 'attacker.com',
2339+
port: null,
2340+
path: '/',
2341+
query: null,
2342+
fragment: null
2343+
},
2344+
accessors: {
2345+
protocol: 'hTTps',
2346+
username: '',
2347+
password: '',
2348+
port: '',
2349+
path: '/',
2350+
query: '',
2351+
fragment: '',
2352+
resource: '/',
2353+
authority: 'attacker.com',
2354+
origin: 'hTTps://attacker.com',
2355+
userinfo: '',
2356+
subdomain: '',
2357+
domain: 'attacker.com',
2358+
tld: 'com',
2359+
directory: '/',
2360+
filename: '',
2361+
suffix: '',
2362+
hash: '',
2363+
search: '',
2364+
host: 'attacker.com',
2365+
hostname: 'attacker.com'
2366+
},
2367+
is: {
2368+
urn: false,
2369+
url: true,
2370+
relative: false,
2371+
name: true,
2372+
sld: false,
2373+
ip: false,
2374+
ip4: false,
2375+
ip6: false,
2376+
idn: false,
2377+
punycode: false
2378+
}
23302379
}, {
23312380
name: 'no slash protocol ftp',
23322381
url: 'ftp:attacker.com',

0 commit comments

Comments
 (0)