fix: "allow always" for commands with paths (#23558)

This commit is contained in:
Tommaso Sciortino
2026-03-23 17:25:31 +00:00
committed by GitHub
parent 517961b2eb
commit daf3691841
2 changed files with 5 additions and 7 deletions

View File

@@ -119,8 +119,10 @@ describe('getCommandRoots', () => {
expect(getCommandRoots('ls -l')).toEqual(['ls']);
});
it('should handle paths and return the binary name', () => {
expect(getCommandRoots('/usr/local/bin/node script.js')).toEqual(['node']);
it('should handle paths and return the full path', () => {
expect(getCommandRoots('/usr/local/bin/node script.js')).toEqual([
'/usr/local/bin/node',
]);
});
it('should return an empty array for an empty string', () => {

View File

@@ -264,11 +264,7 @@ function normalizeCommandName(raw: string): string {
return raw.slice(1, -1);
}
}
const trimmed = raw.trim();
if (!trimmed) {
return trimmed;
}
return trimmed.split(/[\\/]/).pop() ?? trimmed;
return raw.trim();
}
function extractNameFromNode(node: Node): string | null {