Skip to content

Commit

Permalink
Fix custom protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidmohr committed Jan 4, 2024
1 parent 12e3b1b commit 49502ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Expand Up @@ -12,8 +12,10 @@ const supportedProtocols = new Set([

const hasCustomProtocol = urlString => {
try {
const regex = /\./;
const {protocol} = new URL(urlString);
return protocol.endsWith(':') && !supportedProtocols.has(protocol);

return protocol.endsWith(':') && !regex.test(protocol) && !supportedProtocols.has(protocol);
} catch {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions test.js
Expand Up @@ -201,6 +201,7 @@ test('removeExplicitPort option', t => {
t.is(normalizeUrl('https://sindresorhus.com:123', options), 'https://sindresorhus.com');
t.is(normalizeUrl('http://sindresorhus.com:443', options), 'http://sindresorhus.com');
t.is(normalizeUrl('https://sindresorhus.com:80', options), 'https://sindresorhus.com');
t.is(normalizeUrl('sindresorhus.com:123', options), 'http://sindresorhus.com');
});

test('removeSingleSlash option', t => {
Expand Down

0 comments on commit 49502ec

Please sign in to comment.