diff --git a/index.js b/index.js index 47ae24c..c8a4077 100644 --- a/index.js +++ b/index.js @@ -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; } diff --git a/test.js b/test.js index 4c74a88..176cdcf 100644 --- a/test.js +++ b/test.js @@ -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 => {