Settings import function improved (#1234)

This commit is contained in:
nobody 2022-12-04 07:15:39 +01:00
parent 809e96bb41
commit 366fee286a
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
2 changed files with 12 additions and 11 deletions

View File

@ -121,17 +121,10 @@ storageManager.startImportFilePicker = function () {
storageManager.handleImportFilePicker = function () { storageManager.handleImportFilePicker = function () {
return new Promise((resolve) => { return new Promise((resolve) => {
try { let file = document.getElementById('import-file-picker').files[0];
let file = document.getElementById('import-file-picker').files[0]; storageManager._readFile(file)
storageManager._readFile(file) .then(storageManager._validation);
.then(JSON.parse) resolve();
.then(storageManager._validation);
resolve();
} catch (err) {
console.error(`[ LocalCDN ] ${err}`);
alert(err);
}
}); });
}; };
@ -164,6 +157,13 @@ storageManager._readFile = function (file) {
storageManager._validation = function (content) { storageManager._validation = function (content) {
let imported = {}; let imported = {};
try {
JSON.parse(content);
} catch (err) {
console.error(`[ LocalCDN ] ${err}`);
alert(err);
}
// Delete old keys // Delete old keys
if (content.whitelistedDomains !== undefined) { if (content.whitelistedDomains !== undefined) {
content.allowlistedDomains = content.whitelistedDomains; content.allowlistedDomains = content.whitelistedDomains;

View File

@ -54,6 +54,7 @@
<p>Improved</p> <p>Improved</p>
<ul> <ul>
<li>Block all non GET requests to CDN (<a href="https://codeberg.org/nobody/LocalCDN/issues/1226">#1226</a>)</li> <li>Block all non GET requests to CDN (<a href="https://codeberg.org/nobody/LocalCDN/issues/1226">#1226</a>)</li>
<li>Settings import function improved (<a href="https://codeberg.org/nobody/LocalCDN/issues/1234">#1234</a>)</li>
</ul> </ul>
<p>Fixed</p> <p>Fixed</p>
<ul> <ul>