diff --git a/src/parse.ts b/src/parse.ts index c5bb710..8f27802 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -24,7 +24,7 @@ export function parseURL (input: string = '', defaultProto?: string): ParsedURL return defaultProto ? parseURL(defaultProto + input) : parsePath(input) } - const [protocol = '', auth, hostAndPath] = (input.replace(/\\/g, '/').match(/([^:/]+:)?\/\/([^/@]+@)?(.*)/) || []).splice(1) + const [protocol = '', auth, hostAndPath = ''] = (input.replace(/\\/g, '/').match(/([^:/]+:)?\/\/([^/@]+@)?(.*)/) || []).splice(1) const [host = '', path = ''] = (hostAndPath.match(/([^/?#]*)(.*)?/) || []).splice(1) const { pathname, search, hash } = parsePath(path)