Skip to content

fix: preserve percent-encoded path in DisplayURL - #13788

Open
happysnaker wants to merge 1 commit into
cli:trunkfrom
happysnaker:fix-percent-encoded-url
Open

fix: preserve percent-encoded path in DisplayURL#13788
happysnaker wants to merge 1 commit into
cli:trunkfrom
happysnaker:fix-percent-encoded-url

Conversation

@happysnaker

Copy link
Copy Markdown
Contributor

Summary

Fixes #13546

DisplayURL was using u.Path which is the unescaped version of the URL path. This caused branch names with special characters (like quotes) to be displayed incorrectly in the terminal when using gh pr create --web.

For example, a branch named test-"quoted"-branch-pr would display as:

https://github.com/OWNER/REPO/compare/...test-"quoted"-branch-pr

Instead of the correct:

https://github.com/OWNER/REPO/compare/...test-%22quoted%22-branch-pr

Changes

Uses u.RawPath (when available) instead of u.Path to preserve the original percent-encoding from the URL.

@happysnaker
happysnaker requested a review from a team as a code owner July 3, 2026 10:12
@happysnaker
happysnaker requested a review from babakks July 3, 2026 10:12
@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed ready-for-review and removed needs-triage needs to be reviewed labels Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for your pull request! While it doesn't meet all of our standard requirements, it appears to be a small, focused contribution and has been routed to the team for review.

Note: We still encourage linking to an issue with the help wanted label when possible, as it helps us prioritize and track contributions.

@happysnaker
happysnaker force-pushed the fix-percent-encoded-url branch from 5ef3685 to 2537a3b Compare July 3, 2026 11:15
@happysnaker

Copy link
Copy Markdown
Contributor Author

The build failures on macOS/Windows/Ubuntu appear to be pre-existing infrastructure issues unrelated to this change. The lint, govulncheck, and all integration tests pass. The change is local to internal/text/text.go and only affects the DisplayURL helper function.

Comment thread internal/text/text.go
// Preserve percent-encoding from the original URL path
if u.RawPath != "" {
path = u.RawPath
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

u.RawPath is only populated when the raw path differs from the default escaping of u.Path, so this misses the common case. e.g. https://x/a%20b decodes Path to "a b" whose canonical escape is "a%20b", which matches raw, so RawPath stays "" and you fall back to the decoded Path. u.EscapedPath() handles both and is what you want here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve percent-encoded branch names in gh pr create display URLs

2 participants