@nka212bg/backend-utils 0.1.9 → 0.1.10

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.
Files changed (2) hide show
  1. package/misc.js +10 -3
  2. package/package.json +1 -1
package/misc.js CHANGED
@@ -415,8 +415,15 @@ 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(url, {
419
- headers: { "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0" },
418
+ let fetchRes = await fetch(tempUrl.href, {
419
+ headers: {
420
+ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0 google facebook linkedin",
421
+ Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
422
+ "Accept-Language": "en-US,en;q=0.5",
423
+ "Accept-Encoding": "gzip, deflate, br",
424
+ Path: tempUrl.pathname,
425
+ Authority: tempUrl.hostname,
426
+ },
420
427
  });
421
428
 
422
429
  const sizeKb = parseInt(Number(fetchRes.headers?.get("content-length")) / 1000);
@@ -426,7 +433,7 @@ exports.urlMetadata = async ({ url }) => {
426
433
 
427
434
  contentType = `${contentGroup}/${fileType}`;
428
435
 
429
- if (/html|xhtml/.test(fileType)) {
436
+ if (/x?html/.test(fileType)) {
430
437
  dataType = "html";
431
438
  } else if (/image|audio|video|application/.test(contentGroup) && !/^xml|json|javascript/.test(fileType)) {
432
439
  dataType = "dataSrc";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nka212bg/backend-utils",
3
3
  "author": "nka212bg",
4
- "version": "0.1.9",
4
+ "version": "0.1.10",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
7
  "@maxmind/geoip2-node": "^5.0.0",