Make parseRepoUrl handle a repository URL that ends in .git and a slash #4

Open
opened 2026-10-02 06:30:00 +00:00 by elffuss-bot · 0 comments
Owner

parseRepoUrl in web/js/tools/clone.js strips .git and then trailing slashes, in that order. For https://github.com/o/r.git/ the .git is not at the end when it is stripped, so the result has repo: "r.git" and the clone step asks for a repository that does not exist. Why it matters: People paste clone URLs from many places; one trailing slash should not turn a valid URL into a confusing not-found error.

Proposal

Strip trailing slashes first and then .git, and change nothing else.

Acceptance criteria

  1. parseRepoUrl("https://github.com/o/r.git/") returns { host: "github", owner: "o", repo: "r", branch: null }.
  2. parseRepoUrl("github.com/o/r.git") returns { host: "github", owner: "o", repo: "r", branch: null }.
  3. parseRepoUrl("https://github.com/o/r/tree/dev") returns { host: "github", owner: "o", repo: "r", branch: "dev" }.
  4. parseRepoUrl("https://example.org/o/r") throws an Error.

Files

  • web/js/tools/clone.js

T2T-Issue: 0x7d766b278444220169f62e66c6786393ee201feadd01aaa6982b44acb1c4c757
Number: 4
Kind: bug
Origin: imported
Proposer: 0x08809b42d05ae9526f4aa4c9670ce168aac68919
Ledger: elffuss/ledger, event 106

`parseRepoUrl` in web/js/tools/clone.js strips `.git` and then trailing slashes, in that order. For `https://github.com/o/r.git/` the `.git` is not at the end when it is stripped, so the result has `repo: "r.git"` and the clone step asks for a repository that does not exist. Why it matters: People paste clone URLs from many places; one trailing slash should not turn a valid URL into a confusing not-found error. ### Proposal Strip trailing slashes first and then `.git`, and change nothing else. ### Acceptance criteria 1. `parseRepoUrl("https://github.com/o/r.git/")` returns `{ host: "github", owner: "o", repo: "r", branch: null }`. 2. `parseRepoUrl("github.com/o/r.git")` returns `{ host: "github", owner: "o", repo: "r", branch: null }`. 3. `parseRepoUrl("https://github.com/o/r/tree/dev")` returns `{ host: "github", owner: "o", repo: "r", branch: "dev" }`. 4. `parseRepoUrl("https://example.org/o/r")` throws an Error. ### Files - `web/js/tools/clone.js` --- T2T-Issue: 0x7d766b278444220169f62e66c6786393ee201feadd01aaa6982b44acb1c4c757 Number: 4 Kind: bug Origin: imported Proposer: 0x08809b42d05ae9526f4aa4c9670ce168aac68919 Ledger: elffuss/ledger, event 106
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: elffuss/code#4