@uxf/scripts 1.6.0 → 1.6.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/scripts",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/Sitemap.js CHANGED
@@ -27,6 +27,28 @@ const axios = create({
27
27
  withCredentials: true,
28
28
  maxRedirects: 0,
29
29
  timeout: 20000,
30
+ headers: {
31
+ 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
32
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
33
+ 'Accept-Encoding': 'gzip, deflate, br',
34
+ 'Accept-Language': 'en-US,en;q=0.9',
35
+ 'Cache-Control': 'no-cache',
36
+ 'Connection': 'keep-alive',
37
+ 'DNT': '1',
38
+ 'Pragma': 'no-cache',
39
+ 'Sec-Ch-Ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
40
+ 'Sec-Ch-Ua-Arch': '"x86"',
41
+ 'Sec-Ch-Ua-Mobile': '?0',
42
+ 'Sec-Ch-Ua-Platform': '"Windows"',
43
+ 'Sec-Fetch-Dest': 'document',
44
+ 'Sec-Fetch-Mode': 'navigate',
45
+ 'Sec-Fetch-Site': 'cross-site',
46
+ 'Sec-Fetch-User': '?1',
47
+ 'Sec-Fetch-User-Agent': '?1',
48
+ 'TE': 'Trailers',
49
+ 'Upgrade-Insecure-Requests': '1',
50
+ 'X-Requested-With': 'XMLHttpRequest',
51
+ },
30
52
  });
31
53
 
32
54
  module.exports = {
@@ -127,14 +127,15 @@ function createCorrectLinks(incorrectLinks, webUrl) {
127
127
  */
128
128
  async function fetchUrl(url, parentUrl = undefined, ttl = 1) {
129
129
  try {
130
- Sitemap.axios.defaults.maxRedirects = parentUrl ? 1 : 0;
130
+ Sitemap.axios.defaults.maxRedirects = parentUrl ? 3 : 0;
131
+ const encodedUrl = parentUrl ? encodeURI(url) : url;
131
132
 
132
133
  const t0 = performance.now();
133
- const { status } = await Sitemap.axios.get(url);
134
+ const { status } = await Sitemap.axios.get(encodedUrl);
134
135
  const t1 = performance.now();
135
136
 
136
137
  if (status !== 200 && ttl < MAX_TTL) {
137
- return await fetchUrl(url, parentUrl, ttl + 1);
138
+ return await fetchUrl(encodedUrl, parentUrl, ttl + 1);
138
139
  }
139
140
 
140
141
  return {
@@ -393,7 +394,7 @@ module.exports = async function run(sitemapUrl, webUrl, slackChannel, skip, test
393
394
  const ignoredErrorText = createErrorResult(ignoredErrors);
394
395
  logErrors(ignoredErrorText, "\nIngored errors:\n");
395
396
  await sendSlackMessage(errorText, slackChannel);
396
- await sendGoogleChatMessage(errors);
397
+ await sendGoogleChatMessage(errorText);
397
398
  }
398
399
 
399
400
  if (ignoredErrors.length > 0) {