fix: preserve percent-encoded path in DisplayURL - #13788
Conversation
|
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 |
5ef3685 to
2537a3b
Compare
|
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 |
| // Preserve percent-encoding from the original URL path | ||
| if u.RawPath != "" { | ||
| path = u.RawPath | ||
| } |
There was a problem hiding this comment.
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.
Summary
Fixes #13546
DisplayURLwas usingu.Pathwhich 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 usinggh pr create --web.For example, a branch named
test-"quoted"-branch-prwould display as:Instead of the correct:
Changes
Uses
u.RawPath(when available) instead ofu.Pathto preserve the original percent-encoding from the URL.