Skip to content

Commit

Permalink
feat(parseURL): support default proto
Browse files Browse the repository at this point in the history
closes #25
  • Loading branch information
pi0 committed May 17, 2021
1 parent 93e401c commit f0f79f0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export interface ParsedHost {
port: string
}

export function parseURL (input: string = ''): ParsedURL {
export function parseURL (input: string = '', defaultProto?: string): ParsedURL {
if (!hasProtocol(input, true)) {
return parsePath(input)
return defaultProto ? parseURL(defaultProto + input) : parsePath(input)
}

const [protocol = '', auth, hostAndPath] = (input.match(/([^:/]+:)?\/\/([^/@]+@)?(.*)/) || []).splice(1)
Expand Down

0 comments on commit f0f79f0

Please sign in to comment.