From 77b94871db48d0c3e648d06645e1985037559dc5 Mon Sep 17 00:00:00 2001 From: Ankur Patel Date: Wed, 3 Dec 2014 23:16:24 -0500 Subject: [PATCH] Update device regex starting with relative path 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. --- lib/path.js | 2 +- test/simple/test-path-parse-format.js | 1 - test/simple/test-path.js | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/path.js b/lib/path.js index 8b08496b48e9fe..896ef7335c7307 100644 --- a/lib/path.js +++ b/lib/path.js @@ -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 = diff --git a/test/simple/test-path-parse-format.js b/test/simple/test-path-parse-format.js index 4f6e5af45c06e8..7a1b7883b8a78d 100644 --- a/test/simple/test-path-parse-format.js +++ b/test/simple/test-path-parse-format.js @@ -28,7 +28,6 @@ var winPaths = [ 'another_path\\DIR with spaces\\1\\2\\33\\index', '\\foo\\C:', 'file', - '.\\file', // unc '\\\\server\\share\\file_path', diff --git a/test/simple/test-path.js b/test/simple/test-path.js index cdd59bcd5d93ec..11542036e8c90b 100644 --- a/test/simple/test-path.js +++ b/test/simple/test-path.js @@ -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