Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/router-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,16 @@ export function escapeHtml(str: string): string {

export function decodePath(path: string, decodeIgnore?: Array<string>): string {
if (!path) return path

// Fast path: most paths are already decoded and safe.
// Only fall back to the slower scan/regex path when we see a '%' (encoded),
// a backslash (explicitly handled), a control character, or a protocol-relative
// prefix which needs collapsing.
// eslint-disable-next-line no-control-regex
if (!/[%\\\x00-\x1f\x7f]/.test(path) && !path.startsWith('//')) {
return path
}

const re = decodeIgnore
? new RegExp(`${decodeIgnore.join('|')}`, 'gi')
: /%25|%5C/gi
Expand Down
Loading