Created
January 15, 2024 16:37
-
-
Save LorisSigrist/943ca7c3791647381a79020745eecb0a to your computer and use it in GitHub Desktop.
A sequence utility for SvelteKit's reroute hook
This file contains hidden or 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
const rerouteSequence(...reroutes) { | |
return ({ url }) => { | |
for(const reroute of reroutes) { | |
url.pathname = reroute({ url: new URL(url) }) ?? url.pathname | |
} | |
return url.pathname | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment