Skip to content

fix(cli): #1713 decode url-encoded dynamic route params from getparamsfromsegment#1714

Open
jstockdi wants to merge 1 commit into
ProjectEvergreen:masterfrom
Battle-Creek-LLC:bug/issue-1713-dynamic-params-decode
Open

fix(cli): #1713 decode url-encoded dynamic route params from getparamsfromsegment#1714
jstockdi wants to merge 1 commit into
ProjectEvergreen:masterfrom
Battle-Creek-LLC:bug/issue-1713-dynamic-params-decode

Conversation

@jstockdi

Copy link
Copy Markdown
Contributor

Related Issue

Resolves #1713

Documentation

N/A — no user-facing documentation change. This restores the already-documented behavior that dynamic route params round-trip losslessly from getStaticPaths to getBody / getStaticParams.

Summary of Changes

  1. getParamsFromSegment (packages/cli/src/lib/url-utils.js) now decodeURIComponents each URLPattern group value, mirroring the decode already applied to ids/labels/titles in lifecycles/graph.js. Decoding is guarded with try/catch so a malformed value falls back to its raw form, and undefined catch-all group values are passed through untouched.
  2. This makes non-ASCII / spaced slugs (e.g. café, hello world) reach getBody decoded, and fixes the execute-route-module.js param comparison (both sides are now decoded), so getStaticParams pages no longer crash the build.
  3. Added regression test packages/cli/test/cases/build.default.dynamic-params-encoded/: a [slug].js whose getStaticPaths returns café and whose getBody echoes params.slug; asserts the built page contains the decoded café, not caf%C3%A9. Verified failing on unpatched source and passing with the fix.
  4. No breaking changes. Output file/directory paths are unaffected (they derive from the already-decoded getStaticPaths params). Existing dynamic-routing / getStaticPaths / SSR / API-route specs continue to pass.

@jstockdi jstockdi self-assigned this Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic route params are delivered percent-encoded to getBody and getStaticParams

1 participant