linkify-it - v6.1.0
    Preparing search index...

    Class LinkifyIt

    Linkifier instance.

    Index

    Constructors

    • Creates new linkifier instance.

      By default understands:

      • http(s)://... , ftp://..., mailto:... & //... links
      • "fuzzy" emails (foo@bar.com).

      See LinkifyConstructorOptions for available options.

      Parameters

      Returns LinkifyIt

      import { LinkifyIt } from 'linkify-it'

      const linkify = new LinkifyIt({ fuzzyLink: true })

      linkify
      .tlds(require('tlds')) // Reload with full TLD list
      .tlds('onion', true) // Add unofficial `.onion` domain
      .add('ftp:', null) // Disable `ftp:` protocol
      .set({ fuzzyIP: true }) // Enable IPs in fuzzy links

      console.log(linkify.test('Site github.com!')) // true
      console.log(linkify.match('Site github.com!'))

    Properties

    __opts__: Required<LinkifyOptions>

    Methods

    • Add new rule definition.

      schema is a link prefix (usually, protocol name with : at the end, skype: for example). linkify-it makes sure that prefix is not preceded with alphanumeric char and symbols. Only whitespaces and punctuation allowed.

      definition is a rule to check tail after link prefix. To disable an existing rule, pass null.

      Parameters

      Returns this

    • Searches linkifiable pattern and returns true on success or false on fail.

      Parameters

      • text: string

        Text to scan.

      Returns boolean

    • Similar to LinkifyIt.test but checks only specific protocol tail exactly at given position. Returns length of found pattern (0 on fail).

      Parameters

      • text: string

        Text to scan.

      • schema: string

        Rule (schema) name.

      • pos: number

        Text offset to check from.

      Returns number

    • Returns array of found link descriptions or null on fail. We strongly recommend to use LinkifyIt.test first, for best speed.

      Parameters

      • text: string

        Text to scan.

      Returns Match[] | null

    • Returns fully-formed (not fuzzy) link if it starts at the beginning of the string, and null otherwise.

      Parameters

      • text: string

        Text to scan.

      Returns Match | null

    • Load (or merge) new TLDs list. Those are used for fuzzy links (without prefix) to avoid false positives. By default this algorithm is used:

      • hostname with any 2-letter root zones are ok.
      • biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф are ok.
      • encoded (xn--...) root zones are ok.

      If list is replaced, then exact match for 2-chars root zones will be checked.

      Parameters

      • list: string | string[]

        List of TLDs.

      • keepOld: boolean = false

        Merge with current list if true (false by default).

      Returns this

    • Default normalizer (if schema does not define its own).

      Parameters

      • match: Match

        Match to normalize.

      Returns void