@nka212bg/backend-utils 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/misc.js +8 -3
- package/package.json +1 -1
package/misc.js
CHANGED
|
@@ -415,8 +415,13 @@ exports.urlMetadata = async ({ url }) => {
|
|
|
415
415
|
const fxIndex = tempUrl.pathname.lastIndexOf(".");
|
|
416
416
|
fileExtension = fxIndex < 0 ? null : tempUrl.pathname.substring(fxIndex + 1)?.match(/\w+/)[0];
|
|
417
417
|
|
|
418
|
-
let fetchRes = await fetch(
|
|
419
|
-
headers: {
|
|
418
|
+
let fetchRes = await fetch(tempUrl.href, {
|
|
419
|
+
headers: {
|
|
420
|
+
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0 bot/0.1",
|
|
421
|
+
Accept: "*/*",
|
|
422
|
+
"Accept-Language": "en-US,en;q=0.5",
|
|
423
|
+
"Accept-Encoding": "gzip, deflate, br",
|
|
424
|
+
},
|
|
420
425
|
});
|
|
421
426
|
|
|
422
427
|
const sizeKb = parseInt(Number(fetchRes.headers?.get("content-length")) / 1000);
|
|
@@ -426,7 +431,7 @@ exports.urlMetadata = async ({ url }) => {
|
|
|
426
431
|
|
|
427
432
|
contentType = `${contentGroup}/${fileType}`;
|
|
428
433
|
|
|
429
|
-
if (/html
|
|
434
|
+
if (/x?html/.test(fileType)) {
|
|
430
435
|
dataType = "html";
|
|
431
436
|
} else if (/image|audio|video|application/.test(contentGroup) && !/^xml|json|javascript/.test(fileType)) {
|
|
432
437
|
dataType = "dataSrc";
|