mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:25:22 +02:00
fix(parser): add alphanumeric sanitizer to excel header mapping to support characters like % and parenthesis
This commit is contained in:
@@ -239,12 +239,16 @@ const normalizeMonth = (rawMonth: string): string => {
|
|||||||
const getColumnValue = (row: any, aliases: string[]): string => {
|
const getColumnValue = (row: any, aliases: string[]): string => {
|
||||||
const rowKeys = Object.keys(row);
|
const rowKeys = Object.keys(row);
|
||||||
const normalizedRowKeys: Record<string, string> = {};
|
const normalizedRowKeys: Record<string, string> = {};
|
||||||
|
|
||||||
rowKeys.forEach(k => {
|
rowKeys.forEach(k => {
|
||||||
normalizedRowKeys[k.trim().toLowerCase()] = k;
|
// Normalize by removing all non-alphanumeric characters for a bulletproof exact match
|
||||||
|
// e.g., "ACOS %" -> "acos", "Sales (30d)" -> "sales30d"
|
||||||
|
const cleanKey = k.toLowerCase().replace(/[^a-z0-9]/g, '');
|
||||||
|
normalizedRowKeys[cleanKey] = k;
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const alias of aliases) {
|
for (const alias of aliases) {
|
||||||
const lookup = alias.trim().toLowerCase();
|
const lookup = alias.toLowerCase().replace(/[^a-z0-9]/g, '');
|
||||||
if (normalizedRowKeys[lookup]) {
|
if (normalizedRowKeys[lookup]) {
|
||||||
const actualKey = normalizedRowKeys[lookup];
|
const actualKey = normalizedRowKeys[lookup];
|
||||||
const val = row[actualKey];
|
const val = row[actualKey];
|
||||||
|
|||||||
Reference in New Issue
Block a user