diff --git a/src/parse.ts b/src/parse.ts index 8f27802..d3ba214 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -26,7 +26,7 @@ export function parseURL (input: string = '', defaultProto?: string): ParsedURL const [protocol = '', auth, hostAndPath = ''] = (input.replace(/\\/g, '/').match(/([^:/]+:)?\/\/([^/@]+@)?(.*)/) || []).splice(1) const [host = '', path = ''] = (hostAndPath.match(/([^/?#]*)(.*)?/) || []).splice(1) - const { pathname, search, hash } = parsePath(path) + const { pathname, search, hash } = parsePath(path.replace(/\/(?=[A-Za-z]:)/, '')) return { protocol, diff --git a/test/url.test.ts b/test/url.test.ts index a307763..5468296 100644 --- a/test/url.test.ts +++ b/test/url.test.ts @@ -8,6 +8,7 @@ describe('parseURL', () => { { input: 'http://test.com?foo=bar', out: { auth: '', hash: '', host: 'test.com', pathname: '', protocol: 'http:', search: '?foo=bar' } }, { input: '/test', out: { hash: '', pathname: '/test', search: '' } }, { input: 'file:///home/user', out: { auth: '', hash: '', host: '', pathname: '/home/user', protocol: 'file:', search: '' } }, + { input: 'file:///C:/home/user', out: { auth: '', hash: '', host: '', pathname: 'C:/home/user', protocol: 'file:', search: '' } }, { input: 'https://host.name\\@foo.bar/meme3.php?url=http://0.0.0.0/2.svg', out: {