Skip to content

Commit 8d02097

Browse files
committed
Enhanced clone switch detection
1 parent f6909a5 commit 8d02097

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.changeset/chubby-beers-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"simple-git": patch
3+
---
4+
5+
Enhanced clone unsafe switch detection.

simple-git/src/lib/plugins/block-unsafe-operations-plugin.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ import type { SimpleGitPlugin } from './simple-git-plugin';
33
import { GitPluginError } from '../errors/git-plugin-error';
44
import type { SimpleGitPluginConfig } from '../types';
55

6-
const CLONE_OPTIONS = /^\0*(-|--|--no-)[\0\dlsqvnobucj]+\b/;
7-
86
function isConfigSwitch(arg: string | unknown) {
97
return typeof arg === 'string' && arg.trim().toLowerCase() === '-c';
108
}
119

1210
function isCloneSwitch(char: string, arg: string | unknown) {
13-
return Boolean(typeof arg === 'string' && CLONE_OPTIONS.test(arg) && arg.includes(char));
11+
if (typeof arg !== 'string' || !arg.includes(char)) {
12+
return false;
13+
}
14+
15+
const token = arg
16+
.replace(/\0g/, '')
17+
.replace(/^(--no)?-{1,2}/, '')
18+
;
19+
return /^[\dlsqvnobucj]+$/.test(token);
1420
}
1521

1622
function preventProtocolOverride(arg: string, next: string) {

0 commit comments

Comments
 (0)