From f664f4d5acff539ef61c815b8bb222fb6ab0c9b8 Mon Sep 17 00:00:00 2001 From: Emily Hedlund Date: Wed, 18 Mar 2026 17:30:59 -0400 Subject: [PATCH] fix(core): handle Windows paths and update test assertions --- .../core/src/services/forbiddenResourceService.test.ts | 6 +++--- packages/core/src/services/forbiddenResourceService.ts | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) 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.