diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-07-31 14:00:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-31 14:00:19 -0400 |
commit | 11f210375ef64ccf969f1ad3da10dbed00a18fef (patch) | |
tree | 2f36a816892820fcfd7cc7df9d9f6072c8e600d9 /ext/js/language/dictionary-importer.js | |
parent | 454ffaad9658256cb4980ee27eb013606b285edc (diff) |
DictionaryImporter improvements (#1862)
* Improve error message
* Simplify URL for JSON fetching
Diffstat (limited to 'ext/js/language/dictionary-importer.js')
-rw-r--r-- | ext/js/language/dictionary-importer.js | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/ext/js/language/dictionary-importer.js b/ext/js/language/dictionary-importer.js index b931c929..a98e71f2 100644 --- a/ext/js/language/dictionary-importer.js +++ b/ext/js/language/dictionary-importer.js @@ -434,15 +434,13 @@ class DictionaryImporter { async _getImageMedia(context, path, entry) { const {media} = context; - const {dictionary, reading} = entry; + const {dictionary} = entry; - let errorSource = entry.expression; - if (reading.length > 0) { - errorSource += ` (${reading})`; - } - errorSource += dictionary; - - const createError = (message) => new Error(`${message} at path ${JSON.stringify(path)} for ${errorSource}`); + const createError = (message) => { + const {expression, reading} = entry; + const readingSource = reading.length > 0 ? ` (${reading})`: ''; + return new Error(`${message} at path ${JSON.stringify(path)} for ${expression}${readingSource} in ${dictionary}`); + }; // Check if already added let mediaData = media.get(path); @@ -490,7 +488,7 @@ class DictionaryImporter { } async _fetchJsonAsset(url) { - const response = await fetch(chrome.runtime.getURL(url), { + const response = await fetch(url, { method: 'GET', mode: 'no-cors', cache: 'default', |