Skip to content

Commit

Permalink
fix(parse): case insensitive scheme - #412
Browse files Browse the repository at this point in the history
  • Loading branch information
r0hanSH authored and rodneyrehm committed Feb 15, 2022
1 parent 19e54c7 commit 6ea641c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/URI.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@
}

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

// extract protocol
if (string.substring(0, 2) === '//') {
Expand Down
2 changes: 1 addition & 1 deletion src/URI.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions test/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2327,6 +2327,55 @@ var urls = [{
idn: false,
punycode: false
}
}, {
name: 'excessive slash protocol https case-insensitive',
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
}
}, {
name: 'no slash protocol ftp',
url: 'ftp:attacker.com',
Expand Down

0 comments on commit 6ea641c

Please sign in to comment.