Package Exports
- check-links
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (check-links) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
check-links
Robustly checks an array of URLs for liveness.
Install
This module requires node >= 4
.
npm install --save check-links
Usage
const checkLinks = require('check-links')
const results = await checkLinks([
'https://foo.com',
'https://404.com',
])
results['https://foo.com'] // { status: 'alive', statusCode: 200 }
results['https://404.com'] // { status: 'dead', statusCode: 404 }
API
checkLinks
Robustly checks an array of URLs for liveness.
Returns a Map<String, Object>
that maps each input URL to an Object with at least
one property, status
which may be any of alive | dead | error | invalid
. Status
will be alive
if the URL was reachable, dead
if it was definitely not reachable,
error
in the event of repeated transport errors, and invalid
if the URL was parsed
as invalid.
Additionally, the result LinkCheckResult
may contain a statusCode
if the HTTP request to that URL resolved properly.
Type: function (urls, opts): Promise
urls
array<string> Array of urls to testopts
object? Configuration optionsopts.baseUrl
string? Base URL for resolving relative urlsopts.concurrency
number Maximum number of urls to resolve concurrently (optional, default8
)opts.retries
number Number of times to retry resolving a dead URL (optional, default2
)opts.protocols
Set Set of string protocols to accept (defaults tohttp:
andhttps:
) (optional, defaultSet(['http:','https:'])
)
Related
- link-check - Used under the hood, checks whether a given hyperlink is alive or dead.
- remark-lint-no-dead-urls - Remark lint plugin that inspired this module.
License
MIT © Travis Fischer