0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00
astro/.changeset/wet-foxes-walk.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
950 B
Markdown
Raw Normal View History

---
'astro': major
---
`params` passed in `getStaticPaths` are no longer automatically decoded.
### [changed]: `params` aren't decoded anymore.
2024-10-02 06:23:46 -05:00
In Astro v4.x, `params` in were automatically decoded using `decodeURIComponent`.
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`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)) is discouraged for `getStaticPaths` because it decodes more characters than it should, for example `/`, `?`, `#` and more.
```diff
---
export function getStaticPaths() {
return [
+ { params: { id: decodeURI("%5Bpage%5D") } },
- { params: { id: "%5Bpage%5D" } },
]
}
const { id } = Astro.params;
---
```