Skip to content

fix: encode branch names in GitHub links - #1713

Open
Abdullah-Builds wants to merge 1 commit into
anthropics:mainfrom
Abdullah-Builds:fix/encode-branch-names-in-github-links
Open

fix: encode branch names in GitHub links#1713
Abdullah-Builds wants to merge 1 commit into
anthropics:mainfrom
Abdullah-Builds:fix/encode-branch-names-in-github-links

Conversation

@Abdullah-Builds

Copy link
Copy Markdown

Encode branch names in GitHub links

Closes #1712

Summary

Fixes GitHub branch and compare links generated by the action when a valid branch name contains URL-significant characters such as #.

Branch names are now encoded one path segment at a time, so / remains a branch hierarchy separator while # is encoded as %23 instead of becoming a URL fragment.

Changes

  • Add encodeBranchNameForUrl() for Git-ref URL paths.
  • Use it for tracking-comment branch links and fallback branch links.
  • Use it for generated pull-request compare URLs.
  • Add a regression test for claude/fix#123.

Example

Before:

https://github.com/owner/repo/tree/claude/fix#123

After:

https://github.com/owner/repo/tree/claude/fix%23123

Validation

  • git diff --check
  • Added regression coverage in test/comments-common.test.ts

Note: The local environment does not have Bun installed, so the Bun test suite could not be run here.

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.

Branch links break for branch names containing #

1 participant