Skip to content

Commit a7906d1

Browse files
pengx17dimaMachina
andauthoredFeb 10, 2025··
fix: importPage URl decoding should use decodeURIComponent (#4187)
* fix: importPage URl decoding should use decodeURIComponent * Create hungry-beds-brush.md * Update packages/nextra/src/client/pages.ts --------- Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
1 parent a1fda63 commit a7906d1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎.changeset/hungry-beds-brush.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nextra": patch
3+
---
4+
5+
use `decodeURIComponent` instead `decodeURI` to properly decode `&` character

‎packages/nextra/src/client/pages.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export async function importPage(pathSegments: string[] = [], lang = '') {
88
const RouteToFilepath = await getRouteToFilepath(lang)
99

1010
const pathname = pathSegments.join('/')
11-
const decodedPath = decodeURI(pathname) // handle non-"\w" characters
11+
// handle non-"\w" characters,`decodeURIComponent` decodes `%26` (`&`) character
12+
const decodedPath = decodeURIComponent(pathname)
1213

1314
const pagePath = RouteToFilepath[decodedPath]
1415
try {

0 commit comments

Comments
 (0)
Please sign in to comment.