| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b33879d commit e326950
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -585,7 +585,12 @@ const win32 = { | |||
| 585 | 585 | if (from.charCodeAt(fromStart) !== 92/*\*/) | |
| 586 | 586 | break; | |
| 587 | 587 | } | |
| 588 | + // Trim trailing backslashes (applicable to UNC paths only) | ||
| 588 | 589 | var fromEnd = from.length; | |
| 590 | + for (; fromEnd - 1 > fromStart; --fromEnd) { | ||
| 591 | + if (from.charCodeAt(fromEnd - 1) !== 92/*\*/) | ||
| 592 | + break; | ||
| 593 | + } | ||
| 589 | 594 | var fromLen = (fromEnd - fromStart); | |
| 590 | 595 | ||
| 591 | 596 | // Trim any leading backslashes | |
@@ -594,7 +599,12 @@ const win32 = { | |||
| 594 | 599 | if (to.charCodeAt(toStart) !== 92/*\*/) | |
| 595 | 600 | break; | |
| 596 | 601 | } | |
| 602 | + // Trim trailing backslashes (applicable to UNC paths only) | ||
| 597 | 603 | var toEnd = to.length; | |
| 604 | + for (; toEnd - 1 > toStart; --toEnd) { | ||
| 605 | + if (to.charCodeAt(toEnd - 1) !== 92/*\*/) | ||
| 606 | + break; | ||
| 607 | + } | ||
| 598 | 608 | var toLen = (toEnd - toStart); | |
| 599 | 609 | ||
| 600 | 610 | // Compare paths to find the longest common path from root | |
@@ -662,12 +672,12 @@ const win32 = { | |||
| 662 | 672 | // Lastly, append the rest of the destination (`to`) path that comes after | |
| 663 | 673 | // the common path parts | |
| 664 | 674 | if (out.length > 0) | |
| 665 | - return out + toOrig.slice(toStart + lastCommonSep); | ||
| 675 | + return out + toOrig.slice(toStart + lastCommonSep, toEnd); | ||
| 666 | 676 | else { | |
| 667 | 677 | toStart += lastCommonSep; | |
| 668 | 678 | if (toOrig.charCodeAt(toStart) === 92/*\*/) | |
| 669 | 679 | ++toStart; | |
| 670 | - return toOrig.slice(toStart); | ||
| 680 | + return toOrig.slice(toStart, toEnd); | ||
| 671 | 681 | } | |
| 672 | 682 | }, | |
| 673 | 683 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -471,7 +471,12 @@ const relativeTests = [ | |||
| 471 | 471 | ['c:/aaaaa/', 'c:/aaaa/cccc', '..\\aaaa\\cccc'], | |
| 472 | 472 | ['C:\\foo\\bar\\baz\\quux', 'C:\\', '..\\..\\..\\..'], | |
| 473 | 473 | ['C:\\foo\\test', 'C:\\foo\\test\\bar\\package.json', 'bar\\package.json'], | |
| 474 | - ['C:\\foo\\bar\\baz-quux', 'C:\\foo\\bar\\baz', '..\\baz'] | ||
| 474 | + ['C:\\foo\\bar\\baz-quux', 'C:\\foo\\bar\\baz', '..\\baz'], | ||
| 475 | + ['C:\\foo\\bar\\baz', 'C:\\foo\\bar\\baz-quux', '..\\baz-quux'], | ||
| 476 | + ['\\\\foo\\bar', '\\\\foo\\bar\\baz', 'baz'], | ||
| 477 | + ['\\\\foo\\bar\\baz', '\\\\foo\\bar', '..'], | ||
| 478 | + ['\\\\foo\\bar\\baz-quux', '\\\\foo\\bar\\baz', '..\\baz'], | ||
| 479 | + ['\\\\foo\\bar\\baz', '\\\\foo\\bar\\baz-quux', '..\\baz-quux'] | ||
| 475 | 480 | ] | |
| 476 | 481 | ], | |
| 477 | 482 | [ path.posix.relative, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments