(buffer, headers)
| 6281 | }); |
| 6282 | } |
| 6283 | function convertBody(buffer, headers) { |
| 6284 | if (typeof convert !== "function") { |
| 6285 | throw new Error("The package `encoding` must be installed to use the textConverted() function"); |
| 6286 | } |
| 6287 | const ct2 = headers.get("content-type"); |
| 6288 | let charset = "utf-8"; |
| 6289 | let res, str2; |
| 6290 | if (ct2) { |
| 6291 | res = /charset=([^;]*)/i.exec(ct2); |
| 6292 | } |
| 6293 | str2 = buffer.slice(0, 1024).toString(); |
| 6294 | if (!res && str2) { |
| 6295 | res = /<meta.+?charset=(['"])(.+?)\1/i.exec(str2); |
| 6296 | } |
| 6297 | if (!res && str2) { |
| 6298 | res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str2); |
| 6299 | if (!res) { |
| 6300 | res = /<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(str2); |
| 6301 | if (res) { |
| 6302 | res.pop(); |
| 6303 | } |
| 6304 | } |
| 6305 | if (res) { |
| 6306 | res = /charset=(.*)/i.exec(res.pop()); |
| 6307 | } |
| 6308 | } |
| 6309 | if (!res && str2) { |
| 6310 | res = /<\?xml.+?encoding=(['"])(.+?)\1/i.exec(str2); |
| 6311 | } |
| 6312 | if (res) { |
| 6313 | charset = res.pop(); |
| 6314 | if (charset === "gb2312" || charset === "gbk") { |
| 6315 | charset = "gb18030"; |
| 6316 | } |
| 6317 | } |
| 6318 | return convert(buffer, "UTF-8", charset).toString(); |
| 6319 | } |
| 6320 | function isURLSearchParams2(obj) { |
| 6321 | if (typeof obj !== "object" || typeof obj.append !== "function" || typeof obj.delete !== "function" || typeof obj.get !== "function" || typeof obj.getAll !== "function" || typeof obj.has !== "function" || typeof obj.set !== "function") { |
| 6322 | return false; |
no test coverage detected
searching dependent graphs…