summaryrefslogtreecommitdiff
path: root/ext/js/pages
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-07-31 13:04:16 -0400
committerGitHub <noreply@github.com>2021-07-31 13:04:16 -0400
commit454ffaad9658256cb4980ee27eb013606b285edc (patch)
tree85638439db117db833d15a0184ecd45b1f1a83b6 /ext/js/pages
parent00c5ae79833a641ccc5f7d31b6eea3e91db4cb71 (diff)
StringUtil (#1861)
* Add StringUtil class * Use StringUtil
Diffstat (limited to 'ext/js/pages')
-rw-r--r--ext/js/pages/settings/backup-controller.js12
1 files changed, 2 insertions, 10 deletions
diff --git a/ext/js/pages/settings/backup-controller.js b/ext/js/pages/settings/backup-controller.js
index 02ad368c..cf1a6b0c 100644
--- a/ext/js/pages/settings/backup-controller.js
+++ b/ext/js/pages/settings/backup-controller.js
@@ -18,6 +18,7 @@
/* global
* DictionaryController
* OptionsUtil
+ * StringUtil
*/
class BackupController {
@@ -317,17 +318,8 @@ class BackupController {
return warnings;
}
- _utf8Decode(arrayBuffer) {
- try {
- return new TextDecoder('utf-8').decode(arrayBuffer);
- } catch (e) {
- const binaryString = String.fromCharCode.apply(null, new Uint8Array(arrayBuffer));
- return decodeURIComponent(escape(binaryString));
- }
- }
-
async _importSettingsFile(file) {
- const dataString = this._utf8Decode(await this._readFileArrayBuffer(file));
+ const dataString = StringUtil.arrayBufferUtf8Decode(await this._readFileArrayBuffer(file));
const data = JSON.parse(dataString);
// Type check