Special characters are not decoded in dynamic routes using app directory
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64
Binaries:
Node: 16.19.0
npm: 8.19.3
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.3.1-canary.0
eslint-config-next: 13.3.0
react: 18.2.0
react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Metadata (metadata, generateMetadata, next/head, head.js), Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/jolly-dawn-irt1qj?file=%2FREADME.md
To Reproduce
- Create a new Next.js project and enable
appDirunder the experimental settings innext.config.js - Create an
appfolder, as well as a dynamic route inside that folder by creating an[id]folder - Log the
paramsproperty from the page arguments to the console by usingconsole.log(params) - Start the development server using
next dev - Navigate to the dynamic route using characters that should be encoded (such as
:and@) - Observe how the values are not decoded before they are logged to the console
Describe the Bug
Special characters that are passed to dynamic routes (defined by using [id] notation in folders) are not decoded before they are passed to the page.js/layout.js/etc files in Next.js 13 with the app directory. An example being a route defined in my site as /status/[type]/[address], navigating to /status/java/play.hypixel.net:25565 will have the params.address value passed from the page being logged as play.hypixel.net%3A25565. These special characters are not being decoded using decodeURIComponent() before they are passed to the developer.
Expected Behavior
I would expect these special characters to be decoded before I receive them. I have to manually do address = decodeURIComponent(address) for the layout and page files of all dynamic routes.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
next start via my VPS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox and reproduce the issue using an app-directory dynamic route such as /status/[type]/[address]. Trace how the encoded route parameter reaches page.js or layout.js, then verify that values such as play.hypixel.net%3A25565 are decoded before being exposed in params. The issue does not mention a repository file or test to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js, react
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100