Percent sign in getStaticPaths
params breaks astro build
, throws a URI malformed
error.
#12847
Labels
needs triage
Issue needs to be triaged
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No browser involved.
Describe the Bug
When creating dynamic routing under SSG mode, if the params returned by
getStaticPaths()
contain a percent sign (%
) in any of route parameters,astro build
will throw anURI malformed
error.I create a minimal reproducing example at percent-in-route-parameter-bug-reproduce. When building with
astro build
, it will exit with belowing log:I tried to resolve this issue and found there are two
decodeURI
invokes during the dynamic routing pages rendering:astro/packages/astro/src/core/render-context.ts
Line 93 in ebe2aa9
astro/packages/astro/src/core/render/params-and-props.ts
Line 54 in ebe2aa9
According to the docs about params in dynamic routing, we should call
decodeURI
on them before returning fromgetStaticPaths
. But this decoded parameter will be decoded for 2 more times when render pages, one happens in creatingRenderContext
and the other happens ingetProps
call from theRenderContext.render
.I searched in issues and found similar one(#7374), but it's about double URI decoding in SSR mode, not SSG mode.
What's the expected result?
astro build
completes without throwing error.Link to Minimal Reproducible Example
https://github.com/finpluto/percent-in-route-parameter-bug-reproduce
Participation
The text was updated successfully, but these errors were encountered: