Skip to content

Commit 467e1b5

Browse files
committed
fix: resolve Windows case sensitivity with -C option (#8510)
1 parent 57f1c66 commit 467e1b5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

workspaces/config/lib/type-defs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ const validatePath = (data, k, val) => {
1818
if (typeof val !== 'string') {
1919
return false
2020
}
21-
21+
2222
// On Windows, normalize drive letter to uppercase for consistency
2323
let normalizedVal = val
2424
if (process.platform === 'win32' && /^[a-z]:/i.test(val)) {
2525
normalizedVal = val.charAt(0).toUpperCase() + val.slice(1)
2626
}
27-
27+
2828
const result = noptValidatePath(data, k, normalizedVal)
2929
// If validation succeeded and we normalized the path, use the normalized version
3030
if (result && normalizedVal !== val) {

workspaces/config/test/type-defs.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,16 @@ t.equal(validatePath(d, 'somePath', null), false)
2020
t.equal(validatePath(d, 'somePath', 1234), false)
2121
t.equal(validatePath(d, 'somePath', 'false'), true)
2222
t.equal(d.somePath, resolve('false'))
23+
24+
// Test Windows drive letter normalization to achieve 100% coverage
25+
if (process.platform === 'win32') {
26+
const winData = {}
27+
// This should hit the normalization code path and line 31
28+
t.equal(validatePath(winData, 'testPath', 'c:\\test'), true)
29+
t.equal(winData.testPath, 'C:\\test')
30+
31+
// Test that already uppercase drive letter works normally
32+
const winData2 = {}
33+
t.equal(validatePath(winData2, 'testPath2', 'C:\\test'), true)
34+
t.equal(winData2.testPath2, 'C:\\test')
35+
}

0 commit comments

Comments
 (0)