Skip to content

Commit

Permalink
fix(hasProtocol): expand protocol relative url regexp (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Feb 20, 2023
1 parent a30a3ed commit 047c4f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function isRelative(inputString: string) {

const PROTOCOL_STRICT_REGEX = /^\w{2,}:([/\\]{1,2})/;
const PROTOCOL_REGEX = /^\w{2,}:([/\\]{2})?/;
const PROTOCOL_RELATIVE_REGEX = /^[/\\]{2}[^/\\]+/;
const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;

export interface HasProtocolOptions {
acceptRelative?: boolean;
Expand Down
3 changes: 3 additions & 0 deletions test/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ describe("hasProtocol", () => {

// Relative
{ input: "//test.com", out: [false, false, true] },
{ input: "///test.com", out: [false, false, true] },
{ input: "/\t//test.com", out: [false, false, true] },
{ input: "/\\/test.com", out: [false, false, true] },
{ input: "/\\localhost//", out: [false, false, true] },
];

Expand Down

0 comments on commit 047c4f8

Please sign in to comment.