fix(core): handle Windows paths and update test assertions

This commit is contained in:
Emily Hedlund
2026-03-18 17:30:59 -04:00
parent 04892d4fba
commit f664f4d5ac
2 changed files with 8 additions and 5 deletions

View File

@@ -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);

View File

@@ -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.