link-check
Version:
checks whether a hyperlink is alive (200 OK) or dead
15 lines (11 loc) • 490 B
JavaScript
class LinkCheckResult {
constructor(opts, link, statusCode, err) {
opts.aliveStatusCodes = opts.aliveStatusCodes || [ 200 ];
this.link = link;
this.statusCode = statusCode || 0;
this.err = err || null;
this.status = opts.aliveStatusCodes.some((statusCode) => (statusCode instanceof RegExp) ? statusCode.test(this.statusCode) : statusCode === this.statusCode) ? 'alive' : 'dead';
}
}
module.exports = LinkCheckResult;
;