Skip to content

Commit 62b0742

Browse files
committed
fix(router-core): updated function to correctly decode segments with URI encoded characters.
Signed-off-by: leesb971204 <leesb971204@gmail.com>
1 parent db0afdf commit 62b0742

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/router-core/src/path.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { last } from './utils'
1+
import { hasUriEncodedChars, last } from './utils'
22
import type { MatchLocation } from './RouterProvider'
33
import type { AnyPathParams } from './route'
44

@@ -183,7 +183,14 @@ export function parsePathname(pathname?: string): Array<Segment> {
183183

184184
return {
185185
type: 'pathname',
186-
value: part,
186+
value: part.includes('%25')
187+
? part
188+
.split('%25')
189+
.map((segment) => decodeURI(segment))
190+
.join('%25')
191+
: hasUriEncodedChars(part)
192+
? part
193+
: decodeURI(part),
187194
}
188195
}),
189196
)

0 commit comments

Comments
 (0)