Harden campaign import handling
This commit is contained in:
@@ -749,9 +749,22 @@ function parseAddress(value: string): ImportedAddress {
|
||||
}
|
||||
|
||||
function splitCell(value: string, separators: string): string[] {
|
||||
const escaped = separators.split("").map((char) => char.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
||||
if (!escaped) return [value.trim()].filter(Boolean);
|
||||
return value.split(new RegExp(`[${escaped}]+`)).map((item) => item.trim()).filter(Boolean);
|
||||
const separatorSet = new Set(separators.split(""));
|
||||
if (separatorSet.size === 0) return [value.trim()].filter(Boolean);
|
||||
const items: string[] = [];
|
||||
let current = "";
|
||||
for (const char of value) {
|
||||
if (separatorSet.has(char)) {
|
||||
const trimmed = current.trim();
|
||||
if (trimmed) items.push(trimmed);
|
||||
current = "";
|
||||
continue;
|
||||
}
|
||||
current += char;
|
||||
}
|
||||
const trimmed = current.trim();
|
||||
if (trimmed) items.push(trimmed);
|
||||
return items;
|
||||
}
|
||||
|
||||
function parseOptionalBoolean(value: string, fallback: boolean): boolean {
|
||||
|
||||
Reference in New Issue
Block a user