Skip to content

Commit

Permalink
Update device regex starting with relative path
Browse files Browse the repository at this point in the history
paths starting with relative path to another drive for example `../../d:/some/dir/` are not resolved correctly. This regex update fixes it.

Adding and updating tests along with the fix.
  • Loading branch information
ankurp committed Dec 6, 2014
1 parent 616343b commit 77b9487
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function normalizeArray(parts, allowAboveRoot) {
// Regex to split a windows path into three parts: [*, device, slash,
// tail] windows-only
var splitDeviceRe =
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
/^(?:\.\.[\\\/]|\.[\\\/])*([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;

// Regex to split the tail part of the above into [*, dir, basename, ext]
var splitTailRe =
Expand Down
1 change: 0 additions & 1 deletion test/simple/test-path-parse-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var winPaths = [
'another_path\\DIR with spaces\\1\\2\\33\\index',
'\\foo\\C:',
'file',
'.\\file',

// unc
'\\\\server\\share\\file_path',
Expand Down
3 changes: 2 additions & 1 deletion test/simple/test-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ if (isWindows) {
[['c:/', '//dir'], 'c:\\dir'],
[['c:/', '//server/share'], '\\\\server\\share\\'],
[['c:/', '//server//share'], '\\\\server\\share\\'],
[['c:/', '///some//dir'], 'c:\\some\\dir']
[['c:/', '///some//dir'], 'c:\\some\\dir'],
[['c:/some/random/path', '../../../../../d:/some/dir'], 'd:\\some\\dir']
];
} else {
// Posix
Expand Down

0 comments on commit 77b9487

Please sign in to comment.