mirror of
https://github.com/garrytan/gstack.git
synced 2026-07-19 14:07:22 +02:00
fix(gbrain): canonicalize remotes with trailing slashes
This commit is contained in:
@@ -67,6 +67,30 @@ describe("canonicalizeRemote", () => {
|
||||
it("collapses redundant slashes", () => {
|
||||
expect(canonicalizeRemote("https://github.com//foo//bar")).toBe("github.com/foo/bar");
|
||||
});
|
||||
|
||||
it("strips .git even when the URL has a trailing slash", () => {
|
||||
// A remote configured with both a .git suffix and a trailing slash must
|
||||
// canonicalize to the same key as one without — otherwise the same repo
|
||||
// gets two dedup/source-id keys across machines.
|
||||
expect(canonicalizeRemote("https://github.com/garrytan/gstack.git/")).toBe("github.com/garrytan/gstack");
|
||||
expect(canonicalizeRemote("git@github.com:garrytan/gstack.git/")).toBe("github.com/garrytan/gstack");
|
||||
expect(canonicalizeRemote("https://github.com/foo/bar.git///")).toBe("github.com/foo/bar");
|
||||
});
|
||||
|
||||
it("produces the same key with or without a trailing slash", () => {
|
||||
expect(canonicalizeRemote("https://github.com/garrytan/gstack.git/")).toBe(
|
||||
canonicalizeRemote("https://github.com/garrytan/gstack.git")
|
||||
);
|
||||
});
|
||||
|
||||
it("canonicalizes a path remote ending in a .git directory component", () => {
|
||||
// Stripping the `.git` suffix exposes a new trailing slash
|
||||
// ("/repo/.git" → "/repo/") which must also be stripped, or the same
|
||||
// repo splits into two identities.
|
||||
expect(canonicalizeRemote("file:///Users/x/repo/.git")).toBe(
|
||||
canonicalizeRemote("file:///Users/x/repo")
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// ── secretScanFile ─────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user