This commit is contained in:
Timothy Jaeryang Baek 2025-09-26 22:57:38 -05:00
parent 45e1c72613
commit d7c54d92b5

View file

@ -152,7 +152,16 @@
console.log('importHandler', json); console.log('importHandler', json);
try { try {
const data = JSON.parse(json); let data = JSON.parse(json);
// validate data
if (Array.isArray(data)) {
if (data.length === 0) {
toast.error($i18n.t('Please select a valid JSON file'));
return;
}
data = data[0];
}
if (data.type) type = data.type; if (data.type) type = data.type;
if (data.url) url = data.url; if (data.url) url = data.url;
@ -184,7 +193,8 @@
const exportHandler = async () => { const exportHandler = async () => {
// export current connection as json file // export current connection as json file
const json = JSON.stringify({ const json = JSON.stringify([
{
type, type,
url, url,
@ -200,7 +210,8 @@
name: name, name: name,
description: description description: description
} }
}); }
]);
const blob = new Blob([json], { const blob = new Blob([json], {
type: 'application/json' type: 'application/json'