linkinator

  • Version 6.1.2
  • Published
  • 71 kB
  • 10 dependencies
  • MIT license

Install

npm i linkinator
yarn add linkinator
pnpm add linkinator

Overview

Find broken links, missing images, etc in your HTML. Scurry around your site and find all those broken links.

Index

Functions

function check

check: (
options: CheckOptions
) => Promise<{ links: LinkResult[]; passed: boolean }>;
  • Convenience method to perform a scan.

    Parameter options

    CheckOptions to be passed on

function getConfig

getConfig: (flags: Flags) => Promise<Flags>;

    Classes

    class LinkChecker

    class LinkChecker extends EventEmitter {}
    • Instance class used to perform a crawl job.

    method check

    check: (
    options_: CheckOptions
    ) => Promise<{ links: LinkResult[]; passed: boolean }>;
    • Crawl a given url or path, and return a list of visited links along with status codes.

      Parameter options

      Options to use while checking for 404s

    method crawl

    crawl: (options: CrawlOptions) => Promise<void>;
    • Crawl a given url with the provided options. opts List of options used to do the crawl

      Returns

      A list of crawl results consisting of urls and status codes

    method on

    on: {
    (event: 'link', listener: (result: LinkResult) => void): this;
    (event: 'pagestart', listener: (link: string) => void): this;
    (event: 'retry', listener: (details: RetryInfo) => void): this;
    };

      method shouldRetryAfter

      shouldRetryAfter: (response: GaxiosResponse, options: CrawlOptions) => boolean;
      • Check the incoming response for a retry-after header. If present, and if the status was an HTTP 429, calculate the date at which this request should be retried. Ensure the delayCache knows that we're going to wait on requests for this entire host.

        Parameter response

        GaxiosResponse returned from the request

        Parameter opts

        CrawlOptions used during this request

      method shouldRetryOnError

      shouldRetryOnError: (status: number, options: CrawlOptions) => boolean;
      • If the response is a 5xx or synthetic 0 response retry N times.

        Parameter status

        Status returned by request or 0 if request threw.

        Parameter opts

        CrawlOptions used during this request

      Enums

      enum LinkState

      enum LinkState {
      OK = 'OK',
      BROKEN = 'BROKEN',
      SKIPPED = 'SKIPPED',
      }

        member BROKEN

        BROKEN = 'BROKEN'

          member OK

          OK = 'OK'

            member SKIPPED

            SKIPPED = 'SKIPPED'

              Type Aliases

              type CheckOptions

              type CheckOptions = {
              concurrency?: number;
              port?: number;
              path: string | string[];
              recurse?: boolean;
              timeout?: number;
              markdown?: boolean;
              linksToSkip?: string[] | ((link: string) => Promise<boolean>);
              serverRoot?: string;
              directoryListing?: boolean;
              retry?: boolean;
              retryErrors?: boolean;
              retryErrorsCount?: number;
              retryErrorsJitter?: number;
              urlRewriteExpressions?: UrlRewriteExpression[];
              userAgent?: string;
              };

                type CrawlResult

                type CrawlResult = {
                passed: boolean;
                links: LinkResult[];
                };

                  type LinkResult

                  type LinkResult = {
                  url: string;
                  status?: number;
                  state: LinkState;
                  parent?: string;
                  failureDetails?: Array<Error | GaxiosResponse>;
                  };

                    type RetryInfo

                    type RetryInfo = {
                    url: string;
                    secondsUntilRetry: number;
                    status: number;
                    };

                      Package Files (3)

                      Dependencies (10)

                      Dev Dependencies (16)

                      Peer Dependencies (0)

                      No peer dependencies.

                      Badge

                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/linkinator.

                      • Markdown
                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/linkinator)
                      • HTML
                        <a href="https://www.jsdocs.io/package/linkinator"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>