@uxf/scripts 11.62.2 → 11.62.3
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/package.json
CHANGED
|
@@ -15,7 +15,7 @@ const { HTTP_USERNAME, HTTP_PASSWORD } = process.env;
|
|
|
15
15
|
|
|
16
16
|
const DUPLICATES_TITLE = "\n\n\nDuplicated pages in sitemap:\n";
|
|
17
17
|
const MISSING_TITLE = "\n\n\nMissing pages in sitemap:\n";
|
|
18
|
-
const ERROR_TITLE = "\n\n\nErrors:\n"
|
|
18
|
+
const ERROR_TITLE = "\n\n\nErrors:\n";
|
|
19
19
|
|
|
20
20
|
const MAX_TTL = 3;
|
|
21
21
|
const IMAGES_LABEL = "🏞 Images:";
|
|
@@ -29,6 +29,24 @@ const URLS_TO_CHECK = new Set();
|
|
|
29
29
|
|
|
30
30
|
const robotsParser = robotsTxtParser({ userAgent: "uxf-bot", allowOnNeutral: false });
|
|
31
31
|
|
|
32
|
+
const HOSTNAME_ROBOTS_MAP = {
|
|
33
|
+
"fb.me": "facebook.com",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param url {string}
|
|
38
|
+
* @returns {string}
|
|
39
|
+
*/
|
|
40
|
+
function getUrlOrigin(url) {
|
|
41
|
+
const urlObject = new URL(url);
|
|
42
|
+
|
|
43
|
+
if (urlObject.hostname in HOSTNAME_ROBOTS_MAP) {
|
|
44
|
+
return new URL(url.replace(urlObject.hostname, HOSTNAME_ROBOTS_MAP[urlObject.hostname])).origin;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return urlObject.origin;
|
|
48
|
+
}
|
|
49
|
+
|
|
32
50
|
/**
|
|
33
51
|
* @param url {string}
|
|
34
52
|
* @param options {{redirect: boolean, isExternal: boolean}}
|
|
@@ -184,7 +202,7 @@ async function fetchUrl(url, webUrl, parentUrl = undefined, ttl = 1) {
|
|
|
184
202
|
}
|
|
185
203
|
|
|
186
204
|
try {
|
|
187
|
-
const origin =
|
|
205
|
+
const origin = getUrlOrigin(url);
|
|
188
206
|
|
|
189
207
|
if (parentUrl && origin !== webUrl) {
|
|
190
208
|
await robotsParser.useRobotsFor(origin);
|
|
@@ -539,13 +557,15 @@ function getResult(webUrl, sitemapUrls, shouldReportMissing) {
|
|
|
539
557
|
const shouldBeInSitemap = getPagesShouldBeInSitemap(webUrl);
|
|
540
558
|
const errors = TESTED_URLS.filter((r) => r.status !== 200 && r.skipped === false);
|
|
541
559
|
const duplicates = [...new Set(sitemapUrls.filter((item, index, self) => self.indexOf(item) !== index))];
|
|
542
|
-
const missingInSitemap = shouldReportMissing
|
|
560
|
+
const missingInSitemap = shouldReportMissing
|
|
561
|
+
? shouldBeInSitemap.filter((testedUrl) => !sitemapUrls.includes(testedUrl))
|
|
562
|
+
: [];
|
|
543
563
|
const ok = TESTED_URLS.filter((r) => r.status === 200);
|
|
544
564
|
const skippedUrls = TESTED_URLS.filter((r) => r.status !== 200 && r.skipped === true);
|
|
545
565
|
|
|
546
566
|
const errorsSum = missingInSitemap.length + duplicates.length + errors.length;
|
|
547
567
|
|
|
548
|
-
return {errors, duplicates, missingInSitemap, ok, skippedUrls, errorsSum};
|
|
568
|
+
return { errors, duplicates, missingInSitemap, ok, skippedUrls, errorsSum };
|
|
549
569
|
}
|
|
550
570
|
|
|
551
571
|
/**
|