{"id":17306671,"url":"https://github.com/tcort/link-check","last_synced_at":"2025-05-16T08:04:07.061Z","repository":{"id":3427765,"uuid":"49472334","full_name":"tcort/link-check","owner":"tcort","description":"checks whether a hyperlink is alive (`200 OK`) or dead.","archived":false,"fork":false,"pushed_at":"2025-01-27T23:19:47.000Z","size":527,"stargazers_count":43,"open_issues_count":10,"forks_count":30,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-12T02:09:48.127Z","etag":null,"topics":["checker","hyperlinks"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tcort.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-12T03:29:03.000Z","updated_at":"2024-11-05T12:20:49.000Z","dependencies_parsed_at":"2024-05-21T12:39:54.266Z","dependency_job_id":"6eb4e0f7-27bc-486f-8c92-053a30c2910c","html_url":"https://github.com/tcort/link-check","commit_stats":{"total_commits":187,"total_committers":19,"mean_commits":9.842105263157896,"dds":0.2887700534759359,"last_synced_commit":"3263c3b65917375c209928ca2b1ad4102824da36"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcort%2Flink-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcort%2Flink-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcort%2Flink-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcort%2Flink-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcort","download_url":"https://codeload.github.com/tcort/link-check/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493379,"owners_count":22080126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checker","hyperlinks"],"created_at":"2024-10-15T11:59:03.650Z","updated_at":"2025-05-16T08:04:02.051Z","avatar_url":"https://github.com/tcort.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Test library](https://github.com/tcort/link-check/actions/workflows/ci.yml/badge.svg)\n\n# link-check\n\nChecks whether a hyperlink is alive (`200 OK`) or dead.\n\n## Installation\n\n```console\nnpm install --save link-check\n```\n\n## Specification\n\nA link is said to be 'alive' if an HTTP HEAD or HTTP GET for the given URL\neventually ends in a `200 OK` response. To minimize bandwidth, an HTTP HEAD\nis performed. If that fails (e.g. with a `405 Method Not Allowed`), an HTTP\nGET is performed. Redirects are followed.\n\nIn the case of `mailto:` links, this module validates the e-mail address using\n[node-email-verifier](https://www.npmjs.com/package/node-email-verifier).\n\n## API\n\n### linkCheck(link, [opts,] callback)\n\nGiven a `link` and a `callback`, attempt an HTTP HEAD and possibly an HTTP GET.\n\nParameters:\n\n* `url` string containing a URL.\n* `opts` optional options object containing any of the following optional fields:\n  * `anchors` array of anchor strings (e.g. `[ \"#foo\", \"#bar\" ]`) for checking anchor links (e.g. `\u003ca href=\"#foo\"\u003eFoo\u003c/a\u003e`).\n  * `baseUrl` the base URL for relative links.\n  * `timeout` timeout in [zeit/ms](https://www.npmjs.com/package/ms) format. (e.g. `\"2000ms\"`, `20s`, `1m`). Default `10s`.\n  * `user_agent` the user-agent string. Default `${name}/${version}` (e.g. `link-check/4.5.5`)\n  * `aliveStatusCodes` an array of numeric HTTP Response codes which indicate that the link is alive. Entries in this array may also be regular expressions. Example: `[ 200, /^[45][0-9]{2}$/ ]`.  Default `[ 200 ]`.\n  * `headers` a string based attribute value object to send custom HTTP headers. Example: `{ 'Authorization' : 'Basic Zm9vOmJhcg==' }`.\n  * `retryOn429` a boolean indicating whether to retry on a 429 (Too Many Requests) response. When true, if the response has a 429 HTTP code and includes an optional `retry-after` header, a retry will be attempted after the delay indicated in the `retry-after` header. If no `retry-after` header is present in the response or the `retry-after` header value is not valid according to [RFC7231](https://tools.ietf.org/html/rfc7231#section-7.1.3) (value must be in seconds), a default retry delay of 60 seconds will apply. This default can be overriden by the `fallbackRetryDelay` parameter.\n  * `retryCount` the number of retries to be made on a 429 response. Default `2`.\n  * `fallbackRetryDelay` the delay in [zeit/ms](https://www.npmjs.com/package/ms) format. (e.g. `\"2000ms\"`, `20s`, `1m`) for retries on a 429 response when no `retry-after` header is returned or when it has an invalid value. Default is `60s`.\n* `callback` function which accepts `(err, result)`.\n  * `err` an Error object when the operation cannot be completed, otherwise `null`.\n  * `result` an object with the following properties:\n    * `link` the `link` provided as input\n    * `status` a string set to either `alive` or `dead`.\n    * `statusCode` the HTTP status code. Set to `0` if no HTTP status code was returned (e.g. when the server is down).\n    * `err` any connection error that occurred, otherwise `null`.\n\n## Examples\n\n```js\n'use strict';\n\nimport linkCheck from 'link-check';\n\nlinkCheck('http://example.com', function (err, result) {\n    if (err) {\n        console.error(err);\n        return;\n    }\n    console.log(`${result.link} is ${result.status}`);\n});\n```\n\n**With basic authentication:**\n\n```js\n'use strict';\n\nimport linkCheck from 'link-check';\n\nlinkCheck('http://example.com', { headers: { 'Authorization': 'Basic Zm9vOmJhcg==' } }, function (err, result) {\n    if (err) {\n        console.error(err);\n        return;\n    }\n    console.log(`${result.link} is ${result.status}`);\n});\n```\n\n## Testing\n\n```console\nnpm test\n```\n\n## License\n\nSee [LICENSE.md](https://github.com/tcort/link-check/blob/master/LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcort%2Flink-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcort%2Flink-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcort%2Flink-check/lists"}