修复 desi 和 conc 命令参数解析

This commit is contained in:
whyour
2024-07-25 20:53:11 +08:00
parent eddd258614
commit 0da8155bac
2 changed files with 7 additions and 2 deletions
+5 -1
View File
@@ -18,7 +18,11 @@ function expandRange(rangeStr, max) {
const rangeMatch = part.match(/^(\d+)([-~_])(\d+)$/);
if (rangeMatch) {
const [, start, , end] = rangeMatch.map(Number);
return Array.from({ length: end - start + 1 }, (_, i) => start + i);
const step = start < end ? 1 : -1;
return Array.from(
{ length: Math.abs(end - start) + 1 },
(_, i) => start + i * step,
);
}
return Number(part);
});