diff --git a/packages/core/src/services/forbiddenResourceService.test.ts b/packages/core/src/services/forbiddenResourceService.test.ts index 235995b285..d05a8bfabb 100644 --- a/packages/core/src/services/forbiddenResourceService.test.ts +++ b/packages/core/src/services/forbiddenResourceService.test.ts @@ -75,9 +75,9 @@ describe('forbiddenResourceService', () => { expect(resources).toEqual( expect.arrayContaining([ - { path: '/workspace/node_modules', isDirectory: true }, - { path: '/workspace/.env', isDirectory: false }, - { path: '/workspace/secrets', isDirectory: true }, + { absolutePath: '/workspace/node_modules', isDirectory: true }, + { absolutePath: '/workspace/.env', isDirectory: false }, + { absolutePath: '/workspace/secrets', isDirectory: true }, ]), ); expect(resources).toHaveLength(3); diff --git a/packages/core/src/services/forbiddenResourceService.ts b/packages/core/src/services/forbiddenResourceService.ts index 6a26d1c800..4075362dca 100644 --- a/packages/core/src/services/forbiddenResourceService.ts +++ b/packages/core/src/services/forbiddenResourceService.ts @@ -139,8 +139,11 @@ function isResourceForbidden( isDirectory: boolean, ignoreManager: IgnoreManager, ): boolean { - // The `ignore` package expects paths to be relative to the workspace root. - let relativePath = path.relative(workspacePath, resourcePath); + // The `ignore` package expects paths to be relative to the workspace root + // and strictly uses forward slashes (/) as directory separators. + let relativePath = path + .relative(workspacePath, resourcePath) + .replace(/\\/g, '/'); // Directories must end with a trailing slash to correctly match // directory-only rules.