linkinator
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -43,3 +43,9 @@ "use strict"; | ||
} | ||
const results = yield this.crawl({ url: options.path, crawl: true, checkOptions: options }); | ||
const results = yield this.crawl({ | ||
url: options.path, | ||
crawl: true, | ||
checkOptions: options, | ||
results: [], | ||
cache: new Set() | ||
}); | ||
const result = { | ||
@@ -76,9 +82,7 @@ links: results, | ||
return __awaiter(this, void 0, void 0, function* () { | ||
opts.results = opts.results || []; | ||
opts.cache = opts.cache || []; | ||
// Check to see if we've already scanned this url | ||
if (opts.cache.includes(opts.url)) { | ||
if (opts.cache.has(opts.url)) { | ||
return opts.results; | ||
} | ||
opts.cache.push(opts.url); | ||
opts.cache.add(opts.url); | ||
// Check for links that should be skipped | ||
@@ -101,4 +105,4 @@ const skips = opts.checkOptions.linksToSkip | ||
try { | ||
const res = yield gaxios.request({ | ||
method: 'GET', | ||
let res = yield gaxios.request({ | ||
method: opts.crawl ? 'GET' : 'HEAD', | ||
url: opts.url, | ||
@@ -108,2 +112,12 @@ responseType: opts.crawl ? 'text' : 'stream', | ||
}); | ||
// If we got an HTTP 405, the server may not like HEAD. GET instead! | ||
if (res.status === 405) { | ||
res = yield gaxios.request({ | ||
method: 'GET', | ||
url: opts.url, | ||
responseType: 'stream', | ||
validateStatus: () => true | ||
}); | ||
} | ||
// Assume any 2xx status is 👌 | ||
status = res.status; | ||
@@ -110,0 +124,0 @@ if (res.status >= 200 && res.status < 300) { |
{ | ||
"name": "linkinator", | ||
"description": "Find broken links, missing images, etc in your HTML.", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "JustinBeckwith/linkinator", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26181
354