Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percent sign in getStaticPaths params breaks astro build, throws a URI malformed error. #12847

Open
1 task
finpluto opened this issue Dec 28, 2024 · 0 comments
Open
1 task
Labels
needs triage Issue needs to be triaged

Comments

@finpluto
Copy link

finpluto commented Dec 28, 2024

Astro Info

Astro                    v5.1.1
Node                     v22.12.0
System                   Windows (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

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 an URI 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:

 generating static routes 
22:30:44 ▶ src/pages/[name].astro
22:30:44   └─ /Astro%foobar/index.htmlURI malformed

I tried to resolve this issue and found there are two decodeURI invokes during the dynamic routing pages rendering:

  1. const params = getParams(route, decodeURI(pathname));

According to the docs about params in dynamic routing, we should call decodeURI on them before returning from getStaticPaths. But this decoded parameter will be decoded for 2 more times when render pages, one happens in creating RenderContext and the other happens in getProps call from the RenderContext.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

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant