-
Notifications
You must be signed in to change notification settings - Fork 0
feat!: Add Redirector #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
BREAKING CHANGE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a URL redirection feature to the library, allowing users to route from deprecated URLs to new URLs, including cross-routing-universe redirections. The implementation adds a new Redirector class that leverages the existing routing engine's pattern matching capabilities.
Key Changes:
- Added
Redirectorclass for reactive URL redirection with support for pattern matching and cross-universe navigation - Refactored routing helper functions into a new
RouteHelperclass to enable code reuse betweenRouterEngineandRedirector - Extended the type system with
RedirectedRouteInfoandBuildHrefOptionsto support redirection functionality - Added utility functions
buildHrefandcalculateMultiHashFragmentfor constructing complex cross-universe redirect URLs
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/types.ts | Added new types for redirection (RedirectedRouteInfo, BuildHrefOptions) and exposed Location.path property |
| src/lib/kernel/RouteHelper.svelte.ts | Extracted route parsing and testing logic from RouterEngine into reusable RouteHelper class |
| src/lib/kernel/Redirector.svelte.ts | New Redirector class implementing reactive URL redirection with pattern matching |
| src/lib/kernel/buildHref.ts | New utility to combine path and hash pieces from different URLs with query parameter merging |
| src/lib/kernel/calculateMultiHashFragment.ts | New utility to calculate multi-hash fragments while preserving/updating existing paths |
| src/lib/kernel/preserveQuery.ts | Added overload to mergeQueryParams for merging two URLSearchParams directly |
| src/lib/kernel/LocationLite.svelte.ts | Added path property implementation (sanitizes Windows file: URLs) |
| src/lib/kernel/RouterEngine.svelte.ts | Refactored to use RouteHelper class, removed duplicate code |
| src/lib/index.ts | Exported new Redirector class |
| README.md | Added documentation for URL redirection feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Not a kernel function, merely an utilitarian one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes #75.