Disallows link types (allowed-links
)
This rules checks the link destination and disallows certain categories of links:
- External links
- Relative paths
- Relative to document base url
The rule checks links from:
<a href=""></a>
<img src="..">
<link src="..">
<script src=".."></script>
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">
<a href="./foo">
allowRelative
By setting allowRelative
to false
any link with a relative url will be disallowed.
<a href="../foo">
<a href="/foo">
allowAbsolute
By setting allowAbsolute
to false
any link with a absolute url will be disallowed.
<a href="/foo">
<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">
<a href="./foo">