diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 1b1a284c6dffc..57cfe9778464f 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -833,6 +833,7 @@ src/pages/test%25file.astro src/pages/test-file.astro ``` + ### Removed: `astro:ssr-manifest` virtual module (Integration API) @@ -1571,6 +1572,18 @@ If you want to keep the old ID generation for backward compatibility reasons, yo Learn more about [Heading IDs](/en/guides/markdown-content/#heading-ids). +### Changed: Route pathname normalization + + + +Since Astro v6, route pathnames are partially decoded during route normalization. This means `Astro.url.pathname` may differ from `new URL(Astro.request.url).pathname` for percent-encoded route segments. + +This also affects route params derived from normalized pathnames. + +#### What should I do? + +If you need access to the original encoded pathname, use `new URL(Astro.request.url).pathname` instead of `Astro.url.pathname`. + ### Changed: `getStaticPaths()` cannot return `params` of type number diff --git a/src/content/docs/en/reference/api-reference.mdx b/src/content/docs/en/reference/api-reference.mdx index df1dc39c77d6c..309b6cfd6acb0 100644 --- a/src/content/docs/en/reference/api-reference.mdx +++ b/src/content/docs/en/reference/api-reference.mdx @@ -163,9 +163,9 @@ See also: [`params`](/en/reference/routing-reference/#params)

-`url` is a [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object constructed from the current `request.url` value. It is useful for interacting with individual properties of the request URL, like pathname and origin. +A normalized [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object derived from the current `request.url` value. It is useful for interacting with individual properties of the request URL, like pathname and origin. -`Astro.url` is equivalent to doing `new URL(Astro.request.url)`. +Since Astro v6, the pathname may be partially decoded during route normalization. This means `Astro.url.pathname` may differ from `new URL(Astro.request.url).pathname` for percent-encoded route segments. `url` will be a `localhost` URL in dev mode. When building a site, prerendered routes will receive a URL based on the [`site`](/en/reference/configuration-reference/#site) and [`base`](/en/reference/configuration-reference/#base) options. If `site` is not configured, prerendered pages will receive a `localhost` URL during builds as well.