Disallows link types (allowed-links)

This rules checks the link destination and disallows certain categories of links:

The rule checks links from:

Anchor links are ignored by this rule.

Rule details

This rules requires additional configuration to yield errors. By default all links are allowed even when this rule is enabled.

Options

This rule takes an optional object:

{
  "allowExternal": true,
  "allowRelative": true,
  "allowAbsolute": true,
  "allowBase": true
}

allowExternal

By setting allowExternal to false any link to a external resource will be disallowed.

<a href="http://example.net/foo">
error: Link destination must not be external url (allowed-links) at inline:1:10:
> 1 | <a href="http://example.net/foo">
    |          ^^^^^^^^^^^^^^^^^^^^^^


1 error found.

<a href="./foo">

allowRelative

By setting allowRelative to false any link with a relative url will be disallowed.

<a href="../foo">
error: Link destination must not be relative url (allowed-links) at inline:1:10:
> 1 | <a href="../foo">
    |          ^^^^^^


1 error found.

<a href="/foo">

allowAbsolute

By setting allowAbsolute to false any link with a absolute url will be disallowed.

<a href="/foo">
error: Link destination must not be absolute url (allowed-links) at inline:1:10:
> 1 | <a href="/foo">
    |          ^^^^


1 error found.

<a href="../foo">

allowBase

By setting allowBase to false relative urls can be used only if using an explicit path but not when relative to document base url. This is useful when wanting to use relative urls but not rely on <base href=".."> being set correctly.

Effectively this also means that links to files in the same folder must use ./target even if target is valid.

<a href="foo">
error: Relative links must be relative to current folder (allowed-links) at inline:1:10:
> 1 | <a href="foo">
    |          ^^^


1 error found.

<a href="./foo">