Skip to content

Commit 8e09f3c

Browse files
committed
fix(test): use cross-platform path check in globs tests
Replace `startsWith('/')` checks with `path.isAbsolute()` to handle both Unix-style paths (`/path/to/file`) and Windows paths (`C:\path\to\file`) correctly. This fixes test failures on Windows where absolute paths start with drive letters instead of forward slashes. Fixes tests in both glob() and globSync() test suites.
1 parent 8e7e025 commit 8e09f3c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/unit/globs.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Used by Socket tools for file discovery and npm package analysis.
1414
*/
1515

16+
import path from 'node:path'
1617
import {
1718
defaultIgnore,
1819
getGlobMatcher,
@@ -359,7 +360,7 @@ describe('globs', () => {
359360
})
360361
expect(Array.isArray(files)).toBe(true)
361362
if (files.length > 0) {
362-
expect(files[0].startsWith('/')).toBe(true)
363+
expect(path.isAbsolute(files[0])).toBe(true)
363364
}
364365
})
365366

@@ -442,7 +443,7 @@ describe('globs', () => {
442443
})
443444
expect(Array.isArray(files)).toBe(true)
444445
if (files.length > 0) {
445-
expect(files[0].startsWith('/')).toBe(true)
446+
expect(path.isAbsolute(files[0])).toBe(true)
446447
}
447448
})
448449

0 commit comments

Comments
 (0)