File tree Expand file tree Collapse file tree 4 files changed +35
-6
lines changed Expand file tree Collapse file tree 4 files changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,10 @@ checkHttpStatus({
39
39
' Accept' : ' text/html' ,
40
40
},
41
41
},
42
- ' sitemap' : ' https://www.trunkcode.com/page-sitemap.xml' ,
42
+ ' sitemap' : [
43
+ ' https://www.trunkcode.com/page-sitemap.xml' ,
44
+ ' https://www.trunkcode.com/post-sitemap.xml'
45
+ ],
43
46
' skip200' : true , // Do not report the URLs having HTTP code 200.
44
47
});
45
48
```
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
const consoleColumns = require ( './lib/console-columns' ) ;
4
- const fetchFromSitemap = require ( './lib/fetch-from-sitemap' ) ;
4
+ const fetchAllSitemaps = require ( './lib/fetch-from-sitemap' ) ;
5
5
const fs = require ( 'fs' ) ;
6
6
const generateExcel = require ( './lib/generate-excel' ) ;
7
7
const httpList = require ( './lib/http-list' ) ;
@@ -30,7 +30,7 @@ async function checkHttpStatus(config) {
30
30
}
31
31
32
32
if ( config . sitemap ) {
33
- urlsList = await fetchFromSitemap ( config . sitemap ) ;
33
+ urlsList = await fetchAllSitemaps ( config . sitemap ) ;
34
34
} else if ( config . urls && Array . isArray ( config . urls ) ) {
35
35
urlsList = config . urls ;
36
36
}
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const xml2js = require('xml2js');
7
7
* Fetch Sitemap URL and dumb all the URLs from the XML to a variable.
8
8
*/
9
9
function fetchFromSitemap ( sitemapUrl ) {
10
- var errorMessage = 'Error: Sitemap URL returns with status code ' ;
10
+ var errorMessage = 'Error: ' + sitemapUrl + ' returns with status code ';
11
11
var fetchedUrls = [ ] ;
12
12
13
13
return new Promise ( ( resolve ) => {
@@ -42,4 +42,27 @@ function fetchFromSitemap(sitemapUrl) {
42
42
} ) ;
43
43
}
44
44
45
- module . exports = fetchFromSitemap ;
45
+ async function fetchAllSitemaps ( sitemapUrls ) {
46
+ const sitemapUrlsLists = [ ] ;
47
+ const urlsList = [ ] ;
48
+
49
+ var mergeLists = [ ] ;
50
+ for ( const sitemapUrl of sitemapUrls ) {
51
+ sitemapUrlsLists . push ( fetchFromSitemap ( sitemapUrl ) ) ;
52
+ }
53
+
54
+ const allUrls = await Promise . all ( sitemapUrlsLists ) ;
55
+ for ( const singleList of allUrls ) {
56
+ mergeLists = mergeLists . concat ( singleList ) ;
57
+ }
58
+
59
+ for ( const singleUrl of mergeLists ) {
60
+ if ( ! urlsList . includes ( singleUrl ) ) {
61
+ urlsList . push ( singleUrl ) ;
62
+ }
63
+ }
64
+
65
+ return urlsList ;
66
+ }
67
+
68
+ module . exports = fetchAllSitemaps ;
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ checkHttpStatus({
16
16
'Accept' : 'text/html' ,
17
17
} ,
18
18
} ,
19
- 'sitemap' : 'https://www.trunkcode.com/page-sitemap.xml' ,
19
+ 'sitemap' : [
20
+ 'https://www.trunkcode.com/page-sitemap.xml' ,
21
+ 'https://www.trunkcode.com/post-sitemap.xml'
22
+ ] ,
20
23
'skip200' : true ,
21
24
} ) ;
You can’t perform that action at this time.
0 commit comments