Support UNC path beginning with double slashes #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Replacing double slashes '//' to '/' in
toUnix()
causes problem when the path is a UNC path, beginning with double (back)slashes.Examples of such pathes:
See the following Microsoft documents about Windows path names:
https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
Now (with the modified version of
toUnix()
),upath.normalize('\\\\server\\share\\file')
returns '//server/share/file' on Windows but returns '/server/share/file' on Unix. I think this behavior is good in most case, but may be problematic when processing Windows UNC paths on Unix. So I modified the safe versionnormalizeSafe()
to preserve leading double slashes. (Update: same forjoinSafe()
)I noticed a related pull request #37 . Maybe it is good to omit unnecessary
//?/
prefix. However, we need to keep the leading double slashes of the UNC paths.