Reject consecutive slashes and dot-prefixed components in branch validation
This commit is contained in:
parent
f92c5f6c9d
commit
034de8a3fa
|
|
@ -106,6 +106,11 @@ describe("isGitBranchNameSafe", () => {
|
|||
expect(isGitBranchNameSafe(".hidden")).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects consecutive slashes and dot-prefixed components", () => {
|
||||
expect(isGitBranchNameSafe("feat//bar")).toBe(false);
|
||||
expect(isGitBranchNameSafe("feat/.hidden")).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects characters invalid in git refs", () => {
|
||||
expect(isGitBranchNameSafe("bad branch")).toBe(false);
|
||||
expect(isGitBranchNameSafe("x:y")).toBe(false);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ export function isGitBranchNameSafe(name: string): boolean {
|
|||
if (name === "@" || name.startsWith(".") || name.endsWith(".") || name.endsWith("/")) return false;
|
||||
if (name.endsWith(".lock")) return false;
|
||||
if (name.includes("..")) return false;
|
||||
if (name.includes("//")) return false;
|
||||
if (name.includes("/.")) return false;
|
||||
if (name.includes("@{")) return false;
|
||||
if (name.startsWith("/")) return false;
|
||||
for (let i = 0; i < name.length; i++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue