Skip to content

Escape the branch name in GitHub branch URLs [patch] - #387

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/escape-branch-url
Oct 30, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/escape-branch-url

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #386

What was wrong

GetBranchUrl put the raw branch name into the URL. For fix/#123-crash, "Open Branch URL" and "Copy Branch URL" produced …/tree/fix/#123-crash, which a browser reads as path /tree/fix/ plus the fragment #123-crash. A % in a branch name was read as a percent-escape.

Change

  • GetBranchUrl escapes each /-separated segment with Uri.EscapeDataString and keeps the separators. It is now internal so it can be tested.
  • BranchUrlTests pins the cases from the issue: fix/#123-crash gives …/tree/fix/%23123-crash, feature/50% gives …/tree/feature/50%25, and plain feature/foo and main are unchanged.

Verification

  • With the fix temporarily reverted, the # and % cases fail and the plain cases pass. With the fix, all four pass.
  • dotnet test --project BuildMonitor.Test: 147/147 pass.
  • dotnet build -c Release: 0 warnings.

Generated by Claude Code

Open Branch URL and Copy Branch URL interpolated the raw branch name, so
fix/#123-crash became a /fix/ link with a #123-crash fragment and a % read
as a percent-escape. Escape each segment and keep the / separators.

Fixes #386

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW2nrCvY4DyoEF72Nk1
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit b2d53ae into main Oct 30, 2026
16 checks passed
@matt-edmondson
matt-edmondson deleted the fix/escape-branch-url branch October 30, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Open/Copy Branch URL" gives a broken link for branches containing # or % (e.g. fix/#123-crash): the branch name isn't URL-escaped

1 participant