transitive-bullshit / check-links

Robustly checks an array of URLs for liveness. Extremely fast ⚡
MIT License
334 stars 10 forks source link

Option for Failing on Redirects? #13

Open karlhorky opened 3 years ago

karlhorky commented 3 years ago

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).