Skip to content

Instantly share code, notes, and snippets.

@LorisSigrist
Created January 15, 2024 16:37
Show Gist options
  • Save LorisSigrist/943ca7c3791647381a79020745eecb0a to your computer and use it in GitHub Desktop.
Save LorisSigrist/943ca7c3791647381a79020745eecb0a to your computer and use it in GitHub Desktop.
A sequence utility for SvelteKit's reroute hook
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