Skip to content

Commit

Permalink
fix: use lookbehind regex only inside joinRelativeURL (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 18, 2024
1 parent 2dd616e commit 9d481ff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils.ts
Expand Up @@ -14,7 +14,6 @@ const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
const PROTOCOL_SCRIPT_RE = /^[\s\0]*(blob|data|javascript|vbscript):$/i;
const TRAILING_SLASH_RE = /\/$|\/\?|\/#/;
const JOIN_LEADING_SLASH_RE = /^\.?\//;
const JOIN_SEGMENT_SPLIT_RE = /(?<!\/)\/(?!\/)/;

/**
* Check if a path starts with `./` or `../`.
Expand Down Expand Up @@ -346,6 +345,9 @@ export function joinURL(base: string, ...input: string[]): string {
* @group utils
*/
export function joinRelativeURL(..._input: string[]): string {
// Inlined regex to increase browser compatibiltiy for lookbehind (#224)
const JOIN_SEGMENT_SPLIT_RE = /(?<!\/)\/(?!\/)/;

const input = _input.filter(Boolean);

const segments: string[] = [];
Expand Down

0 comments on commit 9d481ff

Please sign in to comment.