-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
links with the same pathname as the current page but different search params are never prefetched #9185
Description
Astro Info
Astro v3.6.0
Node v20.7.0
System macOS (x64)
Package Manager npm
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Links with the same pathname as the current page, but different search params, are never prefetched
What's the expected result?
Links with the same pathname as the current page are prefetched if their search params are different
I don't know whether the current behavior is intended, and just checking search params could have some edge cases (same params, but in a different order in the url string?) But I feel like the current behavior goes against expectations in at least some cases, like pagination, where it's commonly controlled by search query and you'd think it should prefetch the next/previous page of results.
I found this related issue #4963 fixing a bug where it would prefetch the exact same page and I think that introduced the behavior I'm seeing. After the fix, one of the comments raised the same issue I am.
I believe it could be made to also prefetch pages with different search params by adding that case to the check here https://github.com/withastro/astro/blob/04fdc1c613171409ed1a2bd887326e26cdb8b5ef/packages/astro/src/prefetch/index.ts#L227C11-L227C11
Link to Minimal Reproducible Example
I couldn't reproduce it on stackblitz because it involves the url, but I can make one on github if the description and link to the source code aren't enough
Participation
- I am willing to submit a pull request for this issue.