@uxf/scripts 1.6.1 → 1.6.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 +1 -1
- package/src/Sitemap.js +7 -5
- package/src/uxf-sitemap-check/index.js +10 -5
package/package.json
CHANGED
package/src/Sitemap.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const https = require('https');
|
|
1
2
|
const { create } = require("axios");
|
|
2
3
|
const cheerio = require("cheerio");
|
|
3
4
|
|
|
@@ -16,6 +17,10 @@ async function getSitemap(xml) {
|
|
|
16
17
|
return urls;
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
const agent = new https.Agent({
|
|
21
|
+
rejectUnauthorized: false
|
|
22
|
+
});
|
|
23
|
+
|
|
19
24
|
const axios = create({
|
|
20
25
|
auth:
|
|
21
26
|
HTTP_PASSWORD && HTTP_USERNAME
|
|
@@ -27,14 +32,14 @@ const axios = create({
|
|
|
27
32
|
withCredentials: true,
|
|
28
33
|
maxRedirects: 0,
|
|
29
34
|
timeout: 20000,
|
|
35
|
+
httpsAgent: agent,
|
|
30
36
|
headers: {
|
|
31
37
|
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
|
|
32
38
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
|
|
33
39
|
'Accept-Encoding': 'gzip, deflate, br',
|
|
34
|
-
'Accept-Language': 'en-US,en;q=0.9',
|
|
40
|
+
'Accept-Language': 'en-US,en;q=0.9,cs-CZ;q=0.8,cs;q=0.7,de;q=0.6',
|
|
35
41
|
'Cache-Control': 'no-cache',
|
|
36
42
|
'Connection': 'keep-alive',
|
|
37
|
-
'DNT': '1',
|
|
38
43
|
'Pragma': 'no-cache',
|
|
39
44
|
'Sec-Ch-Ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
|
|
40
45
|
'Sec-Ch-Ua-Arch': '"x86"',
|
|
@@ -45,9 +50,6 @@ const axios = create({
|
|
|
45
50
|
'Sec-Fetch-Site': 'cross-site',
|
|
46
51
|
'Sec-Fetch-User': '?1',
|
|
47
52
|
'Sec-Fetch-User-Agent': '?1',
|
|
48
|
-
'TE': 'Trailers',
|
|
49
|
-
'Upgrade-Insecure-Requests': '1',
|
|
50
|
-
'X-Requested-With': 'XMLHttpRequest',
|
|
51
53
|
},
|
|
52
54
|
});
|
|
53
55
|
|
|
@@ -48,6 +48,9 @@ function shouldIgnoreError(url, status, e) {
|
|
|
48
48
|
if ((status === -1 || status === 302) && url.startsWith("https://www.facebook.com/sharer/")) {
|
|
49
49
|
return true;
|
|
50
50
|
}
|
|
51
|
+
if (status === -3) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
51
54
|
|
|
52
55
|
return false;
|
|
53
56
|
}
|
|
@@ -127,8 +130,8 @@ function createCorrectLinks(incorrectLinks, webUrl) {
|
|
|
127
130
|
*/
|
|
128
131
|
async function fetchUrl(url, parentUrl = undefined, ttl = 1) {
|
|
129
132
|
try {
|
|
130
|
-
Sitemap.axios.defaults.maxRedirects = parentUrl ?
|
|
131
|
-
const encodedUrl = parentUrl ? encodeURI(url) : url;
|
|
133
|
+
Sitemap.axios.defaults.maxRedirects = parentUrl ? 10 : 0;
|
|
134
|
+
const encodedUrl = parentUrl ? encodeURI(decodeURI(url)) : url;
|
|
132
135
|
|
|
133
136
|
const t0 = performance.now();
|
|
134
137
|
const { status } = await Sitemap.axios.get(encodedUrl);
|
|
@@ -225,11 +228,11 @@ async function testAllNestedUrls(parentUrl, parentIndex, webUrl) {
|
|
|
225
228
|
const { data } = await axios.get(parentUrl);
|
|
226
229
|
const $ = cheerio.load(data);
|
|
227
230
|
const urls = createCorrectLinks(
|
|
228
|
-
$("a").map((i, node) => $(node).attr("href")),
|
|
231
|
+
$("a[href]").map((i, node) => $(node).attr("href")),
|
|
229
232
|
webUrl,
|
|
230
233
|
);
|
|
231
234
|
const images = createCorrectLinks(
|
|
232
|
-
$("img").map((i, node) => $(node).attr("src")),
|
|
235
|
+
$("img[src]").map((i, node) => $(node).attr("src")),
|
|
233
236
|
webUrl,
|
|
234
237
|
);
|
|
235
238
|
|
|
@@ -347,11 +350,13 @@ async function sendSlackMessage(errorText, slackChannel) {
|
|
|
347
350
|
}
|
|
348
351
|
|
|
349
352
|
/**
|
|
353
|
+
*
|
|
354
|
+
* @param resultErrors {string}
|
|
350
355
|
* @return {Promise<void>}
|
|
351
356
|
*/
|
|
352
357
|
async function sendGoogleChatMessage(resultErrors) {
|
|
353
358
|
await GoogleChat.chatPostMessage({
|
|
354
|
-
text:
|
|
359
|
+
text: resultErrors
|
|
355
360
|
});
|
|
356
361
|
}
|
|
357
362
|
|