Skip to content
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 into
mainfrom
fkling/srch-484-properly-handle-file-paths-that-contain-route-segments
Jun 6, 2024
Merged

fix(search): Properly handle URLs with file paths that contain route segments#63123
fkling merged 2 commits into
mainfrom
fkling/srch-484-properly-handle-file-paths-that-contain-route-segments

Conversation

@fkling

@fkling fkling commented Jun 6, 2024

Copy link
Copy Markdown
Contributor

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.ts and 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 reroute documentation, 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 of params.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

Before After
2024-06-06_14-07 2024-06-06_14-08

Test plan

Manual testing, integration test.

@fkling fkling requested a review from a team June 6, 2024 12:15
@fkling fkling self-assigned this Jun 6, 2024
@cla-bot cla-bot Bot added the cla-signed label Jun 6, 2024

@camdencheek camdencheek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! That's not too bad. Thanks for the fix!

@fkling fkling merged commit 993ed3a into main Jun 6, 2024
@fkling fkling deleted the fkling/srch-484-properly-handle-file-paths-that-contain-route-segments branch June 6, 2024 19:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants