linkinator
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -134,4 +134,5 @@ "use strict"; | ||
let shouldRecurse = false; | ||
let res = undefined; | ||
try { | ||
let res = await gaxios.request({ | ||
res = await gaxios.request({ | ||
method: opts.crawl ? 'GET' : 'HEAD', | ||
@@ -151,12 +152,31 @@ url: opts.url.href, | ||
} | ||
// Assume any 2xx status is 👌 | ||
} | ||
catch (err) { | ||
// request failure: invalid domain name, etc. | ||
// this also occasionally catches too many redirects, but is still valid (e.g. https://www.ebay.com) | ||
// for this reason, we also try doing a GET below to see if the link is valid | ||
} | ||
try { | ||
//some sites don't respond to a stream response type correctly, especially with a HEAD. Try a GET with a text response type | ||
if ((res === undefined || res.status < 200 || res.status >= 300) && | ||
!opts.crawl) { | ||
res = await gaxios.request({ | ||
method: 'GET', | ||
url: opts.url.href, | ||
responseType: 'text', | ||
validateStatus: () => true, | ||
}); | ||
} | ||
} | ||
catch (ex) { | ||
//catch the next failure | ||
} | ||
if (res !== undefined) { | ||
status = res.status; | ||
if (res.status >= 200 && res.status < 300) { | ||
state = LinkState.OK; | ||
} | ||
data = res.data; | ||
shouldRecurse = isHtml(res); | ||
} | ||
catch (err) { | ||
// request failure: invalid domain name, etc. | ||
// Assume any 2xx status is 👌 | ||
if (status >= 200 && status < 300) { | ||
state = LinkState.OK; | ||
} | ||
@@ -163,0 +183,0 @@ const result = { |
{ | ||
"name": "linkinator", | ||
"description": "Find broken links, missing images, etc in your HTML. Scurry around your site and find all those broken links.", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"license": "MIT", | ||
@@ -42,3 +42,3 @@ "repository": "JustinBeckwith/linkinator", | ||
"@types/server-destroy": "^1.0.0", | ||
"@types/sinon": "^7.5.0", | ||
"@types/sinon": "^9.0.0", | ||
"@types/update-notifier": "^4.0.0", | ||
@@ -45,0 +45,0 @@ "assert-rejects": "^1.0.0", |
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
49167
648