Skip to content

Commit

Permalink
Add alert if JSON is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyBF committed Nov 26, 2023
1 parent 8075e0a commit 226702d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions web_ext/sseq_gui/interface/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ document.getElementById('json-upload').addEventListener('change', () => {
const fileReader = new FileReader();
fileReader.onload = e => {
// Remove whitespace to shorten URL
try {
JSON.parse(e.target.result);
} catch (err) {
alert('Invalid JSON file: ' + err);
}
const json = JSON.stringify(JSON.parse(e.target.result));
window.location = `?module_json=${encodeURIComponent(json)}`;
};
Expand Down

0 comments on commit 226702d

Please sign in to comment.