Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use lookbehind regex only inside joinRelativeURL #226

Merged
merged 1 commit into from Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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