| 1 | /** Splits the segments after `/tree/`, `/blob/`, `/raw/` or `/commits/` into a revision and a path: a branch may hold slashes, so the longest branch they start with wins, else the first segment (a tag or a sha). */ |
| 2 | // ponytail: a tag with a slash in its name reads as its first segment only; resolve against the tag list too if one turns up. |
| 3 | export function splitRevision(segments |
| 4 | const full = |
| 5 | const [branch] |
| 6 | .filter((name) |
| 7 | .sort((a, |
| 8 | const revision = |
| 9 | return { revision, |
| 10 | } |
| 11 | |
| 12 | /** Link to a directory (`tree`) or file (`blob`) at a revision. The revision is one encoded segment, so a branch with slashes cannot read as part of the path. */ |
| 13 | export function revisionHref( |
| 14 | base: string, |
| 15 | view: "tree |
| 16 | revision: string, |
| 17 | path: string, |
| 18 | ) { |
| 19 | return `${base} |
| 20 | } |