Skip to content

Commit c9580b5

Browse files
committed
plan: support whitespace-separated mileage paste batches
1 parent 2bb29af commit c9580b5

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

static/plan.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,25 @@
573573
function parseMileagePasteValues(rawText) {
574574
const normalized = String(rawText || "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
575575
if (!normalized.trim()) return { values: [] };
576+
const hasGridSeparators = normalized.includes("\n") || normalized.includes("\t");
577+
if (!hasGridSeparators) {
578+
const spaceTokens = normalized.trim().split(/\s+/).filter((item) => String(item || "").trim().length > 0);
579+
if (spaceTokens.length > 1) {
580+
const values = [];
581+
for (let idx = 0; idx < spaceTokens.length; idx += 1) {
582+
const rawCell = String(spaceTokens[idx] || "").trim();
583+
const parsed = Number.parseFloat(rawCell.replace(/,/g, ""));
584+
if (!Number.isFinite(parsed) || parsed < 0) {
585+
return {
586+
error: `Invalid mileage "${rawCell}" at position ${idx + 1}.`,
587+
values: [],
588+
};
589+
}
590+
values.push(parsed > 0 ? formatSessionValue(parsed) : "");
591+
}
592+
return { values };
593+
}
594+
}
576595
const lines = normalized.split("\n");
577596
while (lines.length > 0 && !String(lines[lines.length - 1] || "").trim()) {
578597
lines.pop();

0 commit comments

Comments
 (0)