Skip to content

Commit 068f0d1

Browse files
authored
fix(router-core): skip URL parsing for safe 'to' props (#6442)
1 parent 9939b02 commit 068f0d1

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

packages/react-router/src/link.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ export function useLinkProps<
156156
}
157157
return hrefOption.href
158158
}
159+
const isSafeInternal =
160+
typeof to === 'string' &&
161+
to.charCodeAt(0) === 47 && // '/'
162+
to.charCodeAt(1) !== 47 // but not '//'
163+
if (isSafeInternal) return undefined
159164
try {
160165
new URL(to as any)
161166
// Block dangerous protocols like javascript:, data:, vbscript:

0 commit comments

Comments
 (0)