Skip to content

Database diagrams editor that allows you to visualize and design your DB with a single query.

fix(import json): for Check Script Result, default with quotes (#358)

Jonathan Fishner1430d2c2365b
diff --git a/src/lib/data/import-metadata/utils.ts b/src/lib/data/import-metadata/utils.ts
index d16a753c..be9fd055 100644
--- a/src/lib/data/import-metadata/utils.ts
+++ b/src/lib/data/import-metadata/utils.ts
@@ -5,17 +5,24 @@ export const fixMetadataJson = async (
metadataJson: string
): Promise<string> => {
await waitFor(1000);
- return metadataJson
- .trim()
- .replace(/^[^{]*/, '') // Remove everything before the first '{'
- .replace(/}[^}]*$/, '}') // Remove everything after the last '}'
- .replace(/^\s+|\s+$/g, '')
- .replace(/^"|"$/g, '')
- .replace(/^'|'$/g, '')
- .replace(/(?<=:\s*)""(?=\s*[,}])/g, '___EMPTY___') // Temporarily replace empty strings
- .replace(/""/g, '"') // Replace remaining double quotes
- .replace(/___EMPTY___/g, '""') // Restore empty strings
- .replace(/\n/g, '');
+
+ // TODO: remove this temporary eslint disable
+ return (
+ metadataJson
+ .trim()
+ .replace(/^[^{]*/, '') // Remove everything before the first '{'
+ .replace(/}[^}]*$/, '}') // Remove everything after the last '}'
+ .replace(/^\s+|\s+$/g, '')
+ .replace(/^"|"$/g, '')
+ .replace(/^'|'$/g, '')
+ /* eslint-disable-next-line no-useless-escape */
+ .replace(/\"/g, '___ESCAPED_QUOTE___') // Temporarily replace empty strings
+ .replace(/(?<=:\s*)""(?=\s*[,}])/g, '___EMPTY___') // Temporarily replace empty strings
+ .replace(/""/g, '"') // Replace remaining double quotes
+ .replace(/___ESCAPED_QUOTE___/g, '"') // Restore empty strings
+ .replace(/___EMPTY___/g, '""') // Restore empty strings
+ .replace(/\n/g, '')
+ );
};
export const isStringMetadataJson = (metadataJsonString: string): boolean => {