-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle optional and rest routes for ISR correctly (#11928)
* fix: handle optional and rest routes for ISR correctly When turning on ISR in adapter-vercel for a route ending in an optional or rest parameter, and that parameter not being set, the regex would yield wrong results. Consider a route like `foo/[...rest]` and the URL is just `/foo`, then the route config for Vercel would turn that into a ISR-request like `foo/[..rest]?pathname/%2Ffoo%2F` - note the trailing slash, which comes from the regex looking like `foo/$1/$2`. This trailing slash which wasn't there before can subsequently lead to the SvelteKit runtime issuing a trailing slash redirect (it thinks we're on /foo/ and issues a redirect to /foo), which is wrong an will lead to infinite redirects in the browser. The fix is to account for optional and rest parameters when constructing the regex for the Vercel route config. * Update packages/adapter-vercel/test/utils.spec.js Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * Update packages/adapter-vercel/utils.js Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * Update .changeset/dirty-points-drop.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * Update packages/adapter-vercel/utils.js Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * make the import unfollowable for typescript --------- Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
- Loading branch information
1 parent
679b598
commit 30c5f7b
Showing
4 changed files
with
163 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@sveltejs/adapter-vercel": patch | ||
--- | ||
|
||
fix: handle optional and rest routes for incremental static regeneration (ISR) correctly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters