1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2024-12-25 01:30:40 +01:00

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

View File

@ -54,6 +54,7 @@
<p>Improved</p>
<ul>
<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>
<p>Fixed</p>
<ul>