feat: new storage link

This commit is contained in:
IlyaDoronin 2024-01-11 16:13:42 +03:00
parent d1a43f23e2
commit 250a4b032f
2 changed files with 36 additions and 31 deletions

@ -36,7 +36,7 @@ export const ViewPage = () => {
const data = await getData(QID)
//@ts-ignore
const settings = data.settings
const parseData = {
const parseData = replaceSpacesToEmptyLines({
settings: {
//@ts-ignore
qid: QID,
@ -50,7 +50,7 @@ export const ViewPage = () => {
pausable: settings.pausable
},
//@ts-ignore
items: replaceSpacesToEmptyLines(
items:
//@ts-ignore
data.items.map((item) => {
const content = JSON.parse(item.c)
@ -63,10 +63,10 @@ export const ViewPage = () => {
type: item.typ,
content
}
})),
}),
//@ts-ignore
cnt: data.cnt
}
})
parseData.items = parseData.items.map((question:any) => {

@ -1,30 +1,35 @@
export const replaceSpacesToEmptyLines = <T = unknown>(object: T): T => {
if (Array.isArray(object)) {
return object.map(replaceSpacesToEmptyLines) as T;
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") {
result[key] = value.replace(/\" \"/g, '""');
// ↓ ЭТО ВРЕМЕННЫЙ КОД ДЛЯ ДЕМОНСТРАЦИИ ДИМЕ
result[key] = value.replace(
"squiz.pena.digital",
"storage.yandexcloud.net"
);
// ↑ ЭТО ВРЕМЕННЫЙ КОД ДЛЯ ДЕМОНСТРАЦИИ ДИМЕ
continue;
}
if (!object || typeof object !== "object") {
return object;
if (typeof value === "object") {
result[key] = replaceSpacesToEmptyLines(value);
continue;
}
const result: Record<string, unknown> = {};
for (const [key, value] of Object.entries(object)) {
if (typeof value === "string") {
result[key] = value.replace(/\" \"/g, '""');
continue;
}
if (typeof value === "object") {
result[key] = replaceSpacesToEmptyLines(value);
continue;
}
result[key] = value;
}
return result as T;
};
result[key] = value;
}
return result as T;
};