Skip to content

Commit ce7c4e2

Browse files
committed
fix(@angular-devkit/core): handle Windows drive letter case insensitivity in path functions
This update ensures that path-related functions in account for the case-insensitivity of drive letters on Windows systems. By addressing this inconsistency, the functionality becomes more robust and aligned with Windows filesystem behavior. Closes #27029 (cherry picked from commit adf9359)
1 parent 0412c53 commit ce7c4e2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Diff for: packages/angular_devkit/core/src/virtual-fs/path.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export function noCacheNormalize(path: string): Path {
233233
// Match absolute windows path.
234234
const original = path;
235235
if (path.match(/^[A-Z]:[/\\]/i)) {
236-
path = '\\' + path[0] + '\\' + path.slice(3);
236+
path = '\\' + path[0].toUpperCase() + '\\' + path.slice(3);
237237
}
238238

239239
// We convert Windows paths as well here.

Diff for: packages/angular_devkit/core/src/virtual-fs/path_spec.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('path', () => {
7373
expect(normalize('\\a\\b\\c')).toBe('/a/b/c');
7474
expect(normalize('.\\a\\b\\c')).toBe('a/b/c');
7575
expect(normalize('C:\\a\\b\\c')).toBe('/C/a/b/c');
76-
expect(normalize('c:\\a\\b\\c')).toBe('/c/a/b/c');
76+
expect(normalize('c:\\a\\b\\c')).toBe('/C/a/b/c');
7777
expect(normalize('A:\\a\\b\\c')).toBe('/A/a/b/c');
7878
expect(() => normalize('A:\\..\\..')).toThrow(new InvalidPathException('A:\\..\\..'));
7979
expect(normalize('\\.\\a\\b\\c')).toBe('/a/b/c');
@@ -131,6 +131,7 @@ describe('path', () => {
131131
['/src/app/sub1/test1', '/src/app/sub2/test2', '../../sub2/test2'],
132132
['/', '/a/b/c', 'a/b/c'],
133133
['/a/b/c', '/d', '../../../d'],
134+
['E:\\abc', 'e:\\abc\\def', 'def'],
134135
];
135136

136137
for (const [from, to, result] of tests) {
@@ -161,8 +162,8 @@ describe('path', () => {
161162
});
162163

163164
it('asWindowsPath', () => {
164-
expect(asWindowsPath(normalize('c:/'))).toBe('c:\\');
165-
expect(asWindowsPath(normalize('c:/b/'))).toBe('c:\\b');
166-
expect(asWindowsPath(normalize('c:/b/c'))).toBe('c:\\b\\c');
165+
expect(asWindowsPath(normalize('c:/'))).toBe('C:\\');
166+
expect(asWindowsPath(normalize('c:/b/'))).toBe('C:\\b');
167+
expect(asWindowsPath(normalize('c:/b/c'))).toBe('C:\\b\\c');
167168
});
168169
});

0 commit comments

Comments
 (0)