Fix Windows drive letter support in path formatting regex

- Update regex pattern to support all drive letters A-Z (not just C:)
- Fix linting warning about unnecessary escape in character class
- Now properly handles paths like D:\Users\, E:\Users\, etc.
This commit is contained in:
Peter Steinberger 2025-06-28 15:15:48 +02:00
parent c8234ded90
commit 816247d8ad

View file

@ -20,7 +20,7 @@
* formatPathForDisplay('/home/bob/projects') // returns '~/projects'
*/
// Compile regex once for better performance
const HOME_PATTERN = /^(?:\/Users\/[^/]+|\/home\/[^/]+|[Cc]:[\/\\]Users[\/\\][^\/\\]+|\/root)/;
const HOME_PATTERN = /^(?:\/Users\/[^/]+|\/home\/[^/]+|[A-Za-z]:[\/\\]Users[\/\\][^\/\\]+|\/root)/;
export function formatPathForDisplay(path: string): string {
if (!path) return '';