Skip to content

Commit

Permalink
fix(router): use encodeURI instead (#4534)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Jun 20, 2023
1 parent 737144a commit 347263e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/qwik-city/buildtime/routing/parse-pathname.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function parseRoutePathname(basePathname: string, pathname: string): Pars
`^${segments
.filter((segment) => segment.length > 0)
.map((s) => {
const segment = decodeURIComponent(s);
const segment = decodeURI(s);
// special case — /[...rest]/ could contain zero segments
const catchAll = /^\[\.\.\.(\w+)?\]$/.exec(segment);
Expand All @@ -46,7 +46,7 @@ export function parseRoutePathname(basePathname: string, pathname: string): Pars
}
return (
encodeURIComponent(content)
encodeURI(content)
// allow users to specify characters on the file system in an encoded manner
.normalize()
// We use [ and ] to denote parameters, so users must encode these on the file
Expand Down
5 changes: 5 additions & 0 deletions packages/qwik-city/buildtime/routing/parse-pathname.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ const tests = {
pattern: /^\/xyz\/%D8%B9%D8%B1%D8%A8%D9%8A\/?$/,
paramNames: [],
},
'/xyz/server$/': {
basePathname: '/',
pattern: /^\/xyz\/server\$\/?$/,
paramNames: [],
},
};

for (const [key, t] of Object.entries(tests)) {
Expand Down

0 comments on commit 347263e

Please sign in to comment.