frontAnswerer/lib/components/ViewPublicationPage/tools/replaceSpacesToEmptyLines.ts

30 lines
653 B
TypeScript
Raw Normal View History

2023-12-29 00:58:19 +00:00
export const replaceSpacesToEmptyLines = <T = unknown>(object: T): T => {
2024-01-11 13:13:42 +00:00
if (Array.isArray(object)) {
return object.map(replaceSpacesToEmptyLines) as T;
}
if (!object || typeof object !== "object") {
return object;
}
const result: Record<string, unknown> = {};
for (const [key, value] of Object.entries(object)) {
if (typeof value === "string") {
2024-05-31 16:41:18 +00:00
result[key] = value.replace("squiz.pena.digital", "storage.yandexcloud.net");
2024-01-11 13:13:42 +00:00
continue;
2023-12-29 00:58:19 +00:00
}
2024-01-11 13:13:42 +00:00
if (typeof value === "object") {
result[key] = replaceSpacesToEmptyLines(value);
continue;
2023-12-29 00:58:19 +00:00
}
2024-01-11 13:13:42 +00:00
result[key] = value;
}
return result as T;
};