Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolver: allow drive-less absolute paths on Windows
Summary: Fix a mostly Meta-specific edge case in Windows resolution. When using absolute paths without a drive letter on Windows, eg `\my\project`, don't use `path.resolve` to normalise to system separators, as this has the unwanted side-effect of prepending the the CWD's drive letter, even when the input is known to be absolute (according to `path.isAbsolute`): On a Windows machine: ``` C:\> node -p "path.isAbsolute('/my/project')" true C:\> node -p "path.isAbsolute('\\my\\project')" true C:\> node -p "path.resolve('/my/project')" C:\my\project ``` This preserves drive-less original paths. It also makes absolute path handling slightly stricter on Windows by not fully normalising the input (e.g., not normalising `C:\foo/../foo/.//bar` to `C:\foo\bar`, but instead using a simple `replaceAll`), which brings it into line with posix path handling - I'm considering this a "fix" rather than breaking, as behaviour for poorly-formed inputs is undefined. Changelog: ``` - **[Fix]**: Treat absolute path specifiers on Windows with the same strictness as posix, and allow absolute paths without drive letters. ``` Reviewed By: huntie Differential Revision: D63175565 fbshipit-source-id: 35ab129f4846579dfe6ae8860d6d49b09cadc4e8
- Loading branch information