Skip to content

Commit

Permalink
Don't throw on upper case URL (#56)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
dchebakov and sindresorhus committed Jun 27, 2020
1 parent eeadb8b commit f835df7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const normalizeUrl = require('normalize-url');

const getUrlsFromQueryParams = url => {
const ret = new Set();
const {searchParams} = (new URL(url.replace(/^(\/\/|(www\.))/, 'http://$2')));
const {searchParams} = (new URL(url.replace(/^(\/\/|(www\.))/i, 'http://$2')));

for (const [, value] of searchParams) {
if (urlRegex({exact: true}).test(value)) {
Expand Down
8 changes: 8 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,11 @@ test('requireSchemeOrWww turned off', t => {
])
);
});

test('supports upper case URL', t => {
const url = 'WWW.POS.COM';

t.notThrows(() => {
getUrls(url, {extractFromQueryString: true});
});
});

0 comments on commit f835df7

Please sign in to comment.