Просмотр исходного кода

fixed issue when reading empty responses

Former-commit-id: 72c45ef3c5c14fa4abbbafe9506c6b9b0baadfc7
Gildas 6 лет назад
Родитель
Сommit
15890979d6
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      lib/single-file/single-file-util.js

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

@@ -225,7 +225,12 @@ this.singlefile.lib.util = this.singlefile.lib.util || (() => {
 				} catch (error) {
 					return { data: options.asBinary ? "data:null;base64," : "", resourceURL };
 				}
-				const buffer = await response.arrayBuffer();
+				let buffer;
+				try {
+					buffer = await response.arrayBuffer();
+				} catch (error) {
+					return { data: options.asBinary ? "data:null;base64," : "", resourceURL };
+				}
 				resourceURL = response.url || resourceURL;
 				let contentType = response.headers.get("content-type");
 				let charset;