link-check
link-check copied to clipboard
It throws error to console
trafficstars
I was checking this url : http://zootwoot.com.
console error:
node:internal/url:552
throw new ERR_INVALID_URL(input);
^
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:371:5)
at onParseError (node:internal/url:552:9)
at new URL (node:internal/url:628:5)
at resolve_url (W:\my business\ig-scrapper\leadshouzz-marketing\node_modules\needle\lib\needle.js:177:12)
at ClientRequest.<anonymous> (W:\my business\ig-scrapper\leadshouzz-marketing\node_modules\needle\lib\needle.js:637:28)
at Object.onceWrapper (node:events:510:26)
at ClientRequest.emit (node:events:390:28)
at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:623:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
at Socket.socketOnData (node:_http_client:487:22) {
input: 'http://',
code: 'ERR_INVALID_URL'
}
It should return an error in the callback instead of throwing error and crashing nodejs process.
linkCheck('http://zootwoot.com', (err, result) => {
if (err) {
console.log('Error: ', err);
return;
}
if (result.status === 'alive') {
console.log(true)
} else if (result.status === 'dead') {
console.log(false)
}
});