This repository was archived by the owner on Sep 30, 2024. It is now read-only.
fix(search): Properly handle URLs with file paths that contain route segments#63123
Merged
fkling merged 2 commits intoJun 6, 2024
Conversation
camdencheek
approved these changes
Jun 6, 2024
camdencheek
left a comment
Member
There was a problem hiding this comment.
Nice! That's not too bad. Thanks for the fix!
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes SRCH-484. See that issue for more information about the problem.
Instead of hardcoding the routes that can contain file paths, I'm using the generated list of routes in
routes.tsand extract any route that ends with a[...path]segment (which, so far at least, is used as the file path parameter).This list is then used to hook into the routing process and encode the file path when any of the routes match. As mentioned in the
reroutedocumentation, this does not affect the URL displayed in the browser. Because the file path is now URL encoded we need to decode it before we can process it further (I grepped for all occurrences ofparams.path).E.g. for https://sourcegraph.sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/client/web-sveltekit/src/routes/[...repo=reporev]/(validrev)/(code)/-/blob/[...path]/+page.svelte
Test plan
Manual testing, integration test.