Skip to content

Commit

Permalink
fix(@angular-devkit/core): handle Windows drive letter case insensiti…
Browse files Browse the repository at this point in the history
…vity 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)
  • Loading branch information
alan-agius4 committed Jan 9, 2025
1 parent 0412c53 commit ce7c4e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/angular_devkit/core/src/virtual-fs/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function noCacheNormalize(path: string): Path {
// Match absolute windows path.
const original = path;
if (path.match(/^[A-Z]:[/\\]/i)) {
path = '\\' + path[0] + '\\' + path.slice(3);
path = '\\' + path[0].toUpperCase() + '\\' + path.slice(3);
}

// We convert Windows paths as well here.
Expand Down
9 changes: 5 additions & 4 deletions packages/angular_devkit/core/src/virtual-fs/path_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('path', () => {
expect(normalize('\\a\\b\\c')).toBe('/a/b/c');
expect(normalize('.\\a\\b\\c')).toBe('a/b/c');
expect(normalize('C:\\a\\b\\c')).toBe('/C/a/b/c');
expect(normalize('c:\\a\\b\\c')).toBe('/c/a/b/c');
expect(normalize('c:\\a\\b\\c')).toBe('/C/a/b/c');
expect(normalize('A:\\a\\b\\c')).toBe('/A/a/b/c');
expect(() => normalize('A:\\..\\..')).toThrow(new InvalidPathException('A:\\..\\..'));
expect(normalize('\\.\\a\\b\\c')).toBe('/a/b/c');
Expand Down Expand Up @@ -131,6 +131,7 @@ describe('path', () => {
['/src/app/sub1/test1', '/src/app/sub2/test2', '../../sub2/test2'],
['/', '/a/b/c', 'a/b/c'],
['/a/b/c', '/d', '../../../d'],
['E:\\abc', 'e:\\abc\\def', 'def'],
];

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

it('asWindowsPath', () => {
expect(asWindowsPath(normalize('c:/'))).toBe('c:\\');
expect(asWindowsPath(normalize('c:/b/'))).toBe('c:\\b');
expect(asWindowsPath(normalize('c:/b/c'))).toBe('c:\\b\\c');
expect(asWindowsPath(normalize('c:/'))).toBe('C:\\');
expect(asWindowsPath(normalize('c:/b/'))).toBe('C:\\b');
expect(asWindowsPath(normalize('c:/b/c'))).toBe('C:\\b\\c');
});
});

0 comments on commit ce7c4e2

Please sign in to comment.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy