0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00
astro/.changeset/wet-foxes-walk.md
Emanuele Stoppa 7febf1f6b5
feat(routing): decode pathname early, don't decode params (#12079)
* feat(routing): decode pathname early

* linting

* Update packages/astro/src/core/fs/index.ts

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>

* address feedback

* Update .changeset/wet-foxes-walk.md

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>

* fix changeset

---------

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
2024-10-02 12:06:42 +01:00

952 B

astro
major

params passed in getStaticPaths are no longer automatically decoded.

[changed]: params aren't decoded anymore.

In Astro v4.x, params in were automatically decoded usingdecodeURIComponent`.

Astro v5.0 doesn't automatically decode params in getStaticPaths anymore, so you'll need to manually decode them yourself if needed

What should I do?

If you were relying on the automatic decode, you'll need to manually decode it using decodeURI.

Note that the use of decodeURIComponent) is discouraged for getStaticPaths because it decodes more characters than it should, for example /, ?, # and more.

---
export function getStaticPaths() {
  return [
+    { params: { id: decodeURI("%5Bpage%5D") } },
-    { params: { id: "%5Bpage%5D" } },
  ]
}

const { id } = Astro.params;
---