fix(gitIgnore): prevent crash/error when processing malformed file paths in GitIgnoreParser (#7553)

Co-authored-by: Srinath Padmanabhan <17151014+srithreepo@users.noreply.github.com>
This commit is contained in:
fuyou
2025-09-03 14:19:20 +08:00
committed by GitHub
parent b5dd6f9ea6
commit 5c2bb990d8
2 changed files with 38 additions and 7 deletions

View File

@@ -181,6 +181,16 @@ src/*.tmp
expect(() => parser.isIgnored('/node_modules')).not.toThrow();
expect(parser.isIgnored('/node_modules')).toBe(false);
});
it('should handle backslash-prefixed files without crashing', () => {
expect(() => parser.isIgnored('\\backslash-file-test.txt')).not.toThrow();
expect(parser.isIgnored('\\backslash-file-test.txt')).toBe(false);
});
it('should handle files with absolute-like names', () => {
expect(() => parser.isIgnored('/backslash-file-test.txt')).not.toThrow();
expect(parser.isIgnored('/backslash-file-test.txt')).toBe(false);
});
});
describe('getIgnoredPatterns', () => {