diff --git a/src/components/views/LinkCheck.svelte b/src/components/views/LinkCheck.svelte index c0218b3f..f227841c 100644 --- a/src/components/views/LinkCheck.svelte +++ b/src/components/views/LinkCheck.svelte @@ -160,11 +160,34 @@ }); return r }) - .flat() + .map(row => flatten(row, 1)) .filter(row => !filter || row[header.indexOf('score')]) .map(row => header.map((col, i) => protectField(row[i])).join($linkCsvType.sep) + '\r\n')]; } + const flatten = (array, depth) => { + // If no depth is specified, default to 1 + if (depth === undefined) { + depth = 1; + } + + // Recursively reduce sub-arrays to the specified depth + const flat = (arr, depth) => { + + // If depth is 0, return the array as-is + if (depth < 1) { + return arr.slice(); + } + + // Otherwise, concatenate into the parent array + return arr.reduce(function (acc, val) { + return acc.concat(Array.isArray(val) ? flat(val, depth - 1) : val); + }, []); + + }; + return flat(array, depth); + }; + \ No newline at end of file +