Creates new linkifier instance.
By default understands:
http(s)://... , ftp://..., mailto:... & //... linksSee LinkifyConstructorOptions for available options.
Recognition options.
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!'))
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.
Rule name (fixed pattern prefix).
Schema definition, or null to disable the rule.
Set recognition options for links without schema.
Recognition options.
Searches linkifiable pattern and returns true on success or false on fail.
Text to scan.
Similar to LinkifyIt.test but checks only specific protocol tail exactly at given position. Returns length of found pattern (0 on fail).
Text to scan.
Rule (schema) name.
Text offset to check from.
Returns array of found link descriptions or null on fail. We strongly
recommend to use LinkifyIt.test first, for best speed.
Text to scan.
Returns fully-formed (not fuzzy) link if it starts at the beginning of the string, and null otherwise.
Text to scan.
Load (or merge) new TLDs list. Those are used for fuzzy links (without prefix) to avoid false positives. By default this algorithm is used:
xn--...) root zones are ok.If list is replaced, then exact match for 2-chars root zones will be checked.
List of TLDs.
Merge with current list if true (false by default).
Default normalizer (if schema does not define its own).
Match to normalize.
Linkifier instance.