@nka212bg/backend-utils 0.1.11 → 0.1.13
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 +18 -3
- package/package.json +1 -1
package/misc.js
CHANGED
|
@@ -417,10 +417,11 @@ exports.urlMetadata = async ({ url }) => {
|
|
|
417
417
|
|
|
418
418
|
let fetchRes = await fetch(tempUrl.href, {
|
|
419
419
|
headers: {
|
|
420
|
-
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0 bot
|
|
421
|
-
Accept: "*/*",
|
|
422
|
-
"Accept-Language": "en-US,en;q=0.5",
|
|
420
|
+
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0 bot",
|
|
423
421
|
"Accept-Encoding": "gzip, deflate, br",
|
|
422
|
+
crawlerbot: "dfbXZuR1VGpP5NciQrIbDl6iObRSmbrX-O3Swo4d4A-aSmAiJVS7abOpEeLF9lxgiErIzRjLRyr7cgCNe5S60",
|
|
423
|
+
connection: "keep-alive",
|
|
424
|
+
Accept: "*/*",
|
|
424
425
|
},
|
|
425
426
|
});
|
|
426
427
|
|
|
@@ -497,3 +498,17 @@ exports.handlebars = ({ template, ...params } = {}) => {
|
|
|
497
498
|
|
|
498
499
|
return template;
|
|
499
500
|
};
|
|
501
|
+
|
|
502
|
+
exports.iterateObject = (obj, callback) => {
|
|
503
|
+
for (let key in obj) {
|
|
504
|
+
if (Array.isArray(obj[key])) {
|
|
505
|
+
callback({ key, value: obj[key], dataType: "array" });
|
|
506
|
+
this.iterateObject(obj[key], callback);
|
|
507
|
+
} else if (typeof obj[key] === "object" && obj[key] !== null) {
|
|
508
|
+
callback({ key, value: obj[key], dataType: typeof obj[key] });
|
|
509
|
+
this.iterateObject(obj[key], callback);
|
|
510
|
+
} else {
|
|
511
|
+
callback({ key, value: obj[key], dataType: typeof obj[key] });
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
};
|