diff options
Diffstat (limited to 'packages/core/src/utils/gitIgnoreParser.ts')
| -rw-r--r-- | packages/core/src/utils/gitIgnoreParser.ts | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/packages/core/src/utils/gitIgnoreParser.ts b/packages/core/src/utils/gitIgnoreParser.ts index 50018bb7..f2422a92 100644 --- a/packages/core/src/utils/gitIgnoreParser.ts +++ b/packages/core/src/utils/gitIgnoreParser.ts @@ -57,24 +57,15 @@ export class GitIgnoreParser implements GitIgnoreFilter { } isIgnored(filePath: string): boolean { - const relativePath = path.isAbsolute(filePath) - ? path.relative(this.projectRoot, filePath) - : filePath; + const resolved = path.resolve(this.projectRoot, filePath); + const relativePath = path.relative(this.projectRoot, resolved); - if ( - relativePath === '' || - relativePath.startsWith('..') || - relativePath === '/' || - relativePath.startsWith('/') - ) { + if (relativePath === '' || relativePath.startsWith('..')) { return false; } - let normalizedPath = relativePath.replace(/\\/g, '/'); - if (normalizedPath.startsWith('./')) { - normalizedPath = normalizedPath.substring(2); - } - + // Even in windows, Ignore expects forward slashes. + const normalizedPath = relativePath.replace(/\\/g, '/'); return this.ig.ignores(normalizedPath); } |
