Skip to content

Commit 79669ec

Browse files
authored
Merge pull request #1670 from dodona-edu/fix/common-prefix-sort
Fix a sorting bug when calculating common prefix
2 parents a6bee7a + 670722b commit 79669ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

web/src/api/utils/file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function commonFilenamePrefix(files: File[]): string {
2020
//debugger;
2121
const first = files[0].path;
2222
// Find all possible locations with a path separator, sort them descending
23-
const splitLocations = Array.from(first.matchAll(/[\\/]/g)).map(r => r.index).sort().reverse();
23+
const splitLocations = Array.from(first.matchAll(/[\\/]/g)).map(r => r.index).sort((a, b) => b - a);
2424
/// If there are none, there is no desirable prefix
2525
if (splitLocations.length == 0) {
2626
return "";

0 commit comments

Comments
 (0)