Ver Fonte

ignore API errors

Former-commit-id: 6260bfaac1948da24af4220401e82a4dc29c8e75
Gildas há 6 anos atrás
pai
commit
fdad0bfdb3
1 ficheiros alterados com 6 adições e 2 exclusões
  1. 6 2
      lib/single-file/single-file-util.js

+ 6 - 2
lib/single-file/single-file-util.js

@@ -119,8 +119,12 @@ this.singlefile.lib.util = this.singlefile.lib.util || (() => {
 					return (new DOMParser()).parseFromString(content, "image/svg+xml");
 				},
 				async digest(algo, text) {
-					const hash = await crypto.subtle.digest(algo, new TextEncoder("utf-8").encode(text));
-					return hex(hash);
+					try {
+						const hash = await crypto.subtle.digest(algo, new TextEncoder("utf-8").encode(text));
+						return hex(hash);
+					} catch (error) {
+						return "";
+					}
 				},
 				getContentSize(content) {
 					return new Blob([content]).size;