* Join path segments and percent-decode them into a single ref name. * * `URL.pathname` keeps `%xx` sequences as-is (e.g. `release%231`), but * downstream code treats the ref value as a raw Git ref. Decoding here keeps * one canonical representation: human-readable in storage and display, and *
(segments: readonly string[])
| 100 | * so the user sees a meaningful error downstream rather than a parse crash. |
| 101 | */ |
| 102 | function decodeRefSegments(segments: readonly string[]): string { |
| 103 | return segments |
| 104 | .map((segment) => { |
| 105 | try { |
| 106 | return decodeURIComponent(segment); |
| 107 | } catch { |
| 108 | return segment; |
| 109 | } |
| 110 | }) |
| 111 | .join('/'); |
| 112 | } |