浏览代码

fix: content type in GMxhr for 'document'

tophf 4 年之前
父节点
当前提交
7445e30e95
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/injected/web/requests.js

+ 2 - 1
src/injected/web/requests.js

@@ -45,7 +45,8 @@ function parseData(req, msg) {
   } else if (responseType === 'json') {
     res = jsonParse(raw);
   } else if (responseType === 'document') {
-    const type = msg.contentType::replace(/^[^;]+/)?.[0] || 'text/html';
+    // Cutting everything after , or ; and trimming whitespace
+    const type = msg.contentType::replace(/[,;].*|\s+/g, '') || 'text/html';
     res = new DOMParser()::parseFromString(raw, type);
   } else if (msg.chunked) {
     // arraybuffer/blob in incognito tabs is transferred as ArrayBuffer encoded in string chunks