check-links icon indicating copy to clipboard operation
check-links copied to clipboard

Option for Failing on Redirects?

Open karlhorky opened this issue 4 years ago • 0 comments

A redirect can often indicate an architectural change of a website, that may lead to broken links later.

Would you be open for adding an option that would fail on redirects?

It would also support this feature in remark-lint-no-dead-urls, which depends on check-links. See further discussion here: https://github.com/davidtheclark/remark-lint-no-dead-urls/issues/15

It won't be as easy as passing in followRedirect: false to got unfortunately, because got still resolves the promise when it encounters a redirect with that option set to false:

Screen Shot 2020-11-28 at 13 10 39

Further reading: https://github.com/davidtheclark/remark-lint-no-dead-urls/issues/15#issuecomment-735223848


I guess probably a potential solution would be to check in the fetchHEAD and fetchGET resolver functions if the res.statusCode is in the 3xx range (if the failOnRedirect option is set).

karlhorky avatar Nov 28 '20 12:11 karlhorky