Repository navigation
Percent-encode file paths in blob finding links - #566
Merged
mickgmdb merged 1 commit intoOct 26, 2026
Merged
Conversation
Paths containing #, ?, % or spaces produced GitHub-style file URLs that browsers cut at the first # or ? and that pointed at the wrong file. Encode the blob path the same way the Bitbucket and Azure links already do.
Merged
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
build_git_urlsbuilds the default (GitHub-style) file link as{repo}/blob/{commit}/{path}#L{line}with the raw path. When the path contains#,?,%or a space, the link breaks: the browser reads the rest of the path as a fragment or query, so it opens the wrong file and drops the line anchor. For example,src/C#/appsettings.jsonlinks tosrc/C.This change percent-encodes the path for the default link. It uses the same character set that the Bitbucket and Azure DevOps branches already use, minus
|, and keeps/separators. Paths without special characters produce the same URLs as before.Fixes #565
Test plan
reporter::tests::blob_links_percent_encode_file_paths. It fails onmain(the link containssrc/C#/100% done?.txt) and passes with this change.cargo test --lib -- reporter::: 47 passed.cargo test --lib: 867 passed, 1 failed.scanner::roots::tests::expand_repo_roots_skips_unreadable_directoriesfails only because the run was as root, which can read the "unreadable" directory. The test is insrc/scanner/roots.rsand does not touch link building.cargo fmt --all -- --checkcargo clippy -p kingfisher-bin --lib --tests -- -D warnings