-
-
Notifications
You must be signed in to change notification settings - Fork 605
Description
Describe the bug
There is an issue with ignored folders when WSL paths are accessed from Windows. I suspect the issue lies in the normalizePathToUnix(sp.isAbsolute(path) ? path : sp.join(cwd, path)) function. [Code reference](
Line 189 in 916334c
| return normalizePathToUnix(sp.isAbsolute(path) ? path : sp.join(cwd, path)); |
Versions (please complete the following information):
- Chokidar version: 3.5.3
- Node version: v20.18.1
- OS version: Windows 11
Additional context
I suspect the issue lies in the toUnix function, which is defined for the ignored path. It returns an invalid path when invoked with a valid WSL path.
Example:
> toUnix('\\wsl.localhost\Ubuntu\home\codex_wsl\one-wsl')
'/wsl.localhostUbuntuhomecodex_wslone-wsl'
The current logic is as follows:
https://github.com/paulmillr/chokidar/blob/916334c8a30eb8340f3b6602267ab23a9e31abd0/src/index.ts#L163C1-L178C3
// If SLASH_SLASH occurs at the beginning of the path, it is not replaced
// because "//StoragePC/DrivePool/Movies" is a valid network path
const toUnix = (string: string) => {
let str = string.replace(BACK_SLASH_RE, SLASH);
let prepend = false;
if (str.startsWith(SLASH_SLASH)) {
prepend = true;
}
while (str.match(DOUBLE_SLASH_RE)) {
str = str.replace(DOUBLE_SLASH_RE, SLASH);
}
if (prepend) {
str = SLASH + str;
}
return str;
};This logic handles some network paths like smb://192.168.1.10/folder (SMB on Linux), but it fails when accessing SMB and WSL paths from Windows, e.g., \\fileserver\sharedfolder and \\wsl.localhost\Ubuntu\home.