Skip to content

Commit 4a89ecd

Browse files
committed
docs: clarify Astro.url and params normalization
1 parent 4c68460 commit 4a89ecd

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/content/docs/en/reference/api-reference.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ In static builds, this will be the `params` returned by `getStaticPaths()` used
137137

138138
When routes are rendered on demand, `params` can be any value matching the path segments in the dynamic route pattern.
139139

140+
`params` values are automatically decoded from route pathnames.
141+
140142
```astro title="src/pages/posts/[id].astro" "Astro.params"
141143
---
142144
import { getPost } from '../api';
@@ -165,7 +167,9 @@ See also: [`params`](/en/reference/routing-reference/#params)
165167

166168
`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.
167169

168-
`Astro.url` is equivalent to doing `new URL(Astro.request.url)`.
170+
`Astro.url` is a normalized `URL` instance derived from `Astro.request.url`.
171+
172+
In Astro v6, the pathname is partially decoded during route normalization, so `Astro.url.pathname` may differ from `new URL(Astro.request.url).pathname` for percent-encoded route segments.
169173

170174
`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.
171175

0 commit comments

Comments
 (0)