const normalizeActions = (rawActions) => { const parts = rawActions?.split("&?") [];…
- User
const normalizeActions = (rawActions) => { const parts = rawActions?.split("&?") || []; const normalizedClauses = [];
codefor (const part of parts) { const items = part.split(",").map(v => stripHTML4(v)); const clause = items.sort().join(" ").trim(); if (clause) normalizedClauses.push(clause); } normalizedClauses.sort((a, b) => a.localeCompare(b)); return normalizedClauses.join(" | "); };AutomationTabs.js:1460 Uncaught TypeError: rawActions.split is not a function at normalizeActions (AutomationTabs.js:1460:33) at findDuplicateRulestype1and3 (AutomationTabs.js:1481:33) at AutomationTabs.js:1306:41
react-dom.development.js:20085 The above error occurred in the <Automati
why this and fix this
- Assistant
The error:
codeUncaught TypeError: rawActions.split is not a function - User
give me the fixed
- Assistant
Certainly! Here's the fixed version of your
normalizeActionsfunction with a type check to ensurerawActionsis a string before calling.split:jsconst normalizeActions = (rawActions) => { if (typeof rawActions !== 'string' || !rawActions) { return ''; } const parts = rawActions.split("&?"); const normalizedClauses = []; for (const part of parts) { const items = part.split(",").map(v => stripHTML4(v)); const clause = items.sort().join(" ").trim(); if (clause) normalizedClauses.push(clause); } normalizedClauses.sort((a, b) => a.localeCompare(b)); return normalizedClauses.join(" | "); };