-
Notifications
You must be signed in to change notification settings - Fork 88
Handle UNC paths in windows (fixes #23) #28
base: master
Are you sure you want to change the base?
Conversation
@sokra Please review this, as it affects the logic outside of just pathToArray (normalisation). |
@@ -38,8 +38,16 @@ function isFile(item) { | |||
|
|||
function pathToArray(path) { | |||
path = normalize(path); | |||
|
|||
var UNC = /^\\\\/.test(path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lower case unc
. all upper case only for constants.
needs test cases for normalization i. e. |
Codecov Report
@@ Coverage Diff @@
## master #28 +/- ##
==========================================
+ Coverage 98.78% 99.25% +0.47%
==========================================
Files 3 3
Lines 246 268 +22
Branches 46 49 +3
==========================================
+ Hits 243 266 +23
+ Misses 3 2 -1
Continue to review full report at Codecov.
|
@sokra are you certain regarding addition/support of this test case? fs.normalize("\\\\a\\b/../c\\d\\..").should.be.eql("\\\\a\\c"); It would make the code quite ugly. That is, I had a few dabs at it, and reverted. The fact that in *nix a file/ directory name can contain a backslash (such as in the case of this test), makes it particularly ugly. Besides, none of the existing test cases would support an equivalent mix of *nix and windows DS, e.g. these will fail: "/a/b/c/..\\.."
// AssertionError: expected '/a/b/c/..\\..' to equal '/a'
"C:\\a\\b\\\c\\../.."
// AssertionError: expected 'C:\\a\\b\\c\\../..' to equal 'C:\\a' am I overlooking something? |
oh yeah, I was wrong. the normalization does only care for |
Whats the need for the addition? What test case am I missing? As it is, all scenarios are covered, as far as my testing goes. |
@sokra I had a second look into this. I don't see what you want to achieve by adding the UNC path support to I am happy to add the support for mixing windows/nix DS, though as I have mentioned earlier, it will require some refactoring and it is not going to work in all cases, since nix paths can contain backwards slashes in file/directory names. |
mixed windows/nix paths will occur. i. e. when resolving So |
if (unc) { | ||
path = '\\' + path; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of this block, could we just do:
var doubleSlashWinRegExp = /(?!^)\\+/g;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
I have fixed the refactoring issue and fixed the join function for use with UNC paths. However, I am leaving the normalisation of a mix of path to issue open. I don't see how it can be solved without major refactoring of normalise.js. |
No description provided.