| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ const bench = common.createBenchmark(main, { | |||
| 9 | 9 | ['C:\\foo\\bar\\baz', 'C:\\foo\\bar\\baz'].join('|'), | |
| 10 | 10 | ['C:\\foo\\BAR\\BAZ', 'C:\\foo\\bar\\baz'].join('|'), | |
| 11 | 11 | ['C:\\foo\\bar\\baz\\quux', 'C:\\'].join('|'), | |
| 12 | + ['c:\\İ\\a\\İ', 'c:\\İ\\b\\İ\\test.txt', '..\\..\\b\\İ\\test.txt'].join('|'), | ||
| 12 | 13 | ], | |
| 13 | 14 | n: [1e5], | |
| 14 | 15 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,12 +22,16 @@ | |||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | 24 | const { | |
| 25 | + ArrayPrototypeJoin, | ||
| 26 | + ArrayPrototypeSlice, | ||
| 25 | 27 | FunctionPrototypeBind, | |
| 26 | 28 | StringPrototypeCharCodeAt, | |
| 27 | 29 | StringPrototypeIndexOf, | |
| 28 | 30 | StringPrototypeLastIndexOf, | |
| 31 | + StringPrototypeRepeat, | ||
| 29 | 32 | StringPrototypeReplace, | |
| 30 | 33 | StringPrototypeSlice, | |
| 34 | + StringPrototypeSplit, | ||
| 31 | 35 | StringPrototypeToLowerCase, | |
| 32 | 36 | } = primordials; | |
| 33 | 37 | ||
@@ -540,6 +544,42 @@ const win32 = { | |||
| 540 | 544 | if (from === to) | |
| 541 | 545 | return ''; | |
| 542 | 546 | ||
| 547 | + if (fromOrig.length !== from.length || toOrig.length !== to.length) { | ||
| 548 | + const fromSplit = StringPrototypeSplit(fromOrig, '\\'); | ||
| 549 | + const toSplit = StringPrototypeSplit(toOrig, '\\'); | ||
| 550 | + if (fromSplit[fromSplit.length - 1] === '') { | ||
| 551 | + fromSplit.pop(); | ||
| 552 | + } | ||
| 553 | + if (toSplit[toSplit.length - 1] === '') { | ||
| 554 | + toSplit.pop(); | ||
| 555 | + } | ||
| 556 | + | ||
| 557 | + const fromLen = fromSplit.length; | ||
| 558 | + const toLen = toSplit.length; | ||
| 559 | + const length = fromLen < toLen ? fromLen : toLen; | ||
| 560 | + | ||
| 561 | + let i; | ||
| 562 | + for (i = 0; i < length; i++) { | ||
| 563 | + if (StringPrototypeToLowerCase(fromSplit[i]) !== StringPrototypeToLowerCase(toSplit[i])) { | ||
| 564 | + break; | ||
| 565 | + } | ||
| 566 | + } | ||
| 567 | + | ||
| 568 | + if (i === 0) { | ||
| 569 | + return toOrig; | ||
| 570 | + } else if (i === length) { | ||
| 571 | + if (toLen > length) { | ||
| 572 | + return ArrayPrototypeJoin(ArrayPrototypeSlice(toSplit, i), '\\'); | ||
| 573 | + } | ||
| 574 | + if (fromLen > length) { | ||
| 575 | + return StringPrototypeRepeat('..\\', fromLen - 1 - i) + '..'; | ||
| 576 | + } | ||
| 577 | + return ''; | ||
| 578 | + } | ||
| 579 | + | ||
| 580 | + return StringPrototypeRepeat('..\\', fromLen - i) + ArrayPrototypeJoin(ArrayPrototypeSlice(toSplit, i), '\\'); | ||
| 581 | + } | ||
| 582 | + | ||
| 543 | 583 | // Trim any leading backslashes | |
| 544 | 584 | let fromStart = 0; | |
| 545 | 585 | while (fromStart < from.length && | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,11 @@ const relativeTests = [ | |||
| 32 | 32 | ['\\\\foo\\baz', '\\\\foo\\baz-quux', '..\\baz-quux'], | |
| 33 | 33 | ['C:\\baz', '\\\\foo\\bar\\baz', '\\\\foo\\bar\\baz'], | |
| 34 | 34 | ['\\\\foo\\bar\\baz', 'C:\\baz', 'C:\\baz'], | |
| 35 | + ['c:\\a\\İ', 'c:\\a\\İ\\test.txt', 'test.txt'], | ||
| 36 | + ['c:\\İ\\a\\İ', 'c:\\İ\\b\\İ\\test.txt', '..\\..\\b\\İ\\test.txt'], | ||
| 37 | + ['c:\\İ\\a\\i̇', 'c:\\İ\\b\\İ\\test.txt', '..\\..\\b\\İ\\test.txt'], | ||
| 38 | + ['c:\\i̇\\a\\İ', 'c:\\İ\\b\\İ\\test.txt', '..\\..\\b\\İ\\test.txt'], | ||
| 39 | + ['c:\\ß\\a\\ß', 'c:\\ß\\b\\ß\\test.txt', '..\\..\\b\\ß\\test.txt'], | ||
| 35 | 40 | ], | |
| 36 | 41 | ], | |
| 37 | 42 | [ path.posix.relative, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments