All Projects → tcort → link-check

tcort / link-check

Licence: ISC license
checks whether a hyperlink is alive (`200 OK`) or dead.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to link-check

Omrchecker
Grade exams fast and accurately using a scanner 🖨 or your phone 🤳.
Stars: ✭ 189 (+440%)
Mutual labels:  checker
node-lintspaces
A validator for checking different kinds of whitespaces in your files.
Stars: ✭ 31 (-11.43%)
Mutual labels:  checker
garn-validator
Create validations with ease
Stars: ✭ 42 (+20%)
Mutual labels:  checker
Nspell
📝 Hunspell compatible spell-checker
Stars: ✭ 195 (+457.14%)
Mutual labels:  checker
Querly
Query Method Calls from Ruby Programs
Stars: ✭ 226 (+545.71%)
Mutual labels:  checker
YANG
🔥 The most efficient, open-source, and unlimited discord nitro generator & checker. 🚀
Stars: ✭ 215 (+514.29%)
Mutual labels:  checker
Xposedchecker
[Deprecated] Check whether your xposed has been enabled.
Stars: ✭ 173 (+394.29%)
Mutual labels:  checker
link-verifier
A tool for verifying links in text-based files
Stars: ✭ 26 (-25.71%)
Mutual labels:  checker
action-my-broken-link-checker
A GitHub Action for checking broken links
Stars: ✭ 32 (-8.57%)
Mutual labels:  checker
health-check
Health Check is an application that provides an API to check the health health_check of some parts and some utilities like ping requests. This application can works as standalone or included in a Django project.
Stars: ✭ 31 (-11.43%)
Mutual labels:  checker
Markdown Link Check
checks that all of the hyperlinks in a markdown text to determine if they are alive or dead
Stars: ✭ 198 (+465.71%)
Mutual labels:  checker
Neomake
Asynchronous linting and make framework for Neovim/Vim
Stars: ✭ 2,512 (+7077.14%)
Mutual labels:  checker
node-w3c-validator
Wrapper for The Nu Html Checker (v.Nu)
Stars: ✭ 28 (-20%)
Mutual labels:  checker
Npmvet
A simple CLI tool for vetting npm package versions
Stars: ✭ 193 (+451.43%)
Mutual labels:  checker
Discord-Token-Checker
🔥Fastest Parallel Request Double-Check Discord Token Checker🔥 Parse discord tokens from any file and directory.
Stars: ✭ 36 (+2.86%)
Mutual labels:  checker
Leaked
Leaked? 2.1 - A Checking tool for Hash codes, Passwords and Emails leaked
Stars: ✭ 184 (+425.71%)
Mutual labels:  checker
flycheck-languagetool
Flycheck support for LanguageTool
Stars: ✭ 44 (+25.71%)
Mutual labels:  checker
lints
Lint all your JavaScript, CSS, HTML, Markdown and Dockerfiles with a single command
Stars: ✭ 14 (-60%)
Mutual labels:  checker
CheckStyle
在协同开发中让代码风格保持一致
Stars: ✭ 25 (-28.57%)
Mutual labels:  checker
ngx-translate-lint
Simple CLI tools for check `ngx-translate` keys
Stars: ✭ 25 (-28.57%)
Mutual labels:  checker

Test library workflow status

link-check

Checks whether a hyperlink is alive (200 OK) or dead.

Installation

npm install --save link-check

Specification

A link is said to be 'alive' if an HTTP HEAD or HTTP GET for the given URL eventually ends in a 200 OK response. To minimize bandwidth, an HTTP HEAD is performed. If that fails (e.g. with a 405 Method Not Allowed), an HTTP GET is performed. Redirects are followed.

In the case of mailto: links, this module validates the e-mail address using isemail.

API

linkCheck(link, [opts,] callback)

Given a link and a callback, attempt an HTTP HEAD and possibly an HTTP GET.

Parameters:

  • url string containing a URL.
  • opts optional options object containing any of the following optional fields:
    • anchors array of anchor strings (e.g. [ "#foo", "#bar" ]) for checking anchor links (e.g. <a >Foo</a>).
    • baseUrl the base URL for relative links.
    • timeout timeout in zeit/ms format. (e.g. "2000ms", 20s, 1m). Default 10s.
    • user_agent the user-agent string. Default ${name}/${version} (e.g. link-check/4.5.5)
    • 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 ].
    • headers a string based attribute value object to send custom HTTP headers. Example: { 'Authorization' : 'Basic Zm9vOmJhcg==' }.
    • 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 (value must be in seconds), a default retry delay of 60 seconds will apply. This default can be overriden by the fallbackRetryDelay parameter.
    • retryCount the number of retries to be made on a 429 response. Default 2.
    • fallbackRetryDelay the delay in zeit/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.
  • callback function which accepts (err, result).
    • err an Error object when the operation cannot be completed, otherwise null.
    • result an object with the following properties:
      • link the link provided as input
      • status a string set to either alive or dead.
      • statusCode the HTTP status code. Set to 0 if no HTTP status code was returned (e.g. when the server is down).
      • err any connection error that occurred, otherwise null.

Examples

'use strict';

const linkCheck = require('link-check');

linkCheck('http://example.com', function (err, result) {
    if (err) {
        console.error(err);
        return;
    }
    console.log(`${result.link} is ${result.status}`);
});

With basic authentication:

'use strict';

const linkCheck = require('link-check');

linkCheck('http://example.com', { headers: { 'Authorization': 'Basic Zm9vOmJhcg==' } }, function (err, result) {
    if (err) {
        console.error(err);
        return;
    }
    console.log(`${result.link} is ${result.status}`);
});

Testing

npm test

License

See LICENSE.md

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].