Skip to content

Commit efaa79b

Browse files
committed
Restore checkRelative to turn off the checks for relative URIs
1 parent 1cf012d commit efaa79b

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

ReadMe.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,19 @@ The default options are:
5959
{
6060
"rules": {
6161
"no-dead-link": {
62+
checkRelative: true,
6263
"baseURI": null,
6364
"ignore": [],
6465
}
6566
}
6667
}
6768
```
6869

70+
### checkRelative
71+
72+
This rule checks the availability of relative URIs by default.
73+
You can turn off the checks by passing `false` to this option.
74+
6975
### baseURI
7076

7177
The base URI to be used for resolving relative URIs.
@@ -93,14 +99,10 @@ An array of URIs to be ignored. These URIs will be skipped from the availability
9399
Example:
94100

95101
```
96-
{
97-
"rules": {
98-
"no-dead-link": {
99-
"ignore": [
100-
"http://example.com/not-exist/index.html"
101-
]
102-
}
103-
}
102+
"no-dead-link": {
103+
"ignore": [
104+
"http://example.com/not-exist/index.html"
105+
]
104106
}
105107
```
106108

src/no-dead-link.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import URL from 'url';
44
import fs from 'fs-extra';
55

66
const DEFAULT_OPTIONS = {
7+
checkRelative: true, // {boolean} `false` disables the checks for relative URIs
78
baseURI: null, // {String|null} a base URI to resolve relative URIs.
89
ignore: [], // {Array<String>} URIs to be skipped from availability checks.
910
};
@@ -130,6 +131,10 @@ function reporter(context, options = {}) {
130131
}
131132

132133
if (isRelative(uri)) {
134+
if (!opts.checkRelative) {
135+
return;
136+
}
137+
133138
const filePath = getFilePath();
134139
const base = opts.baseURI || filePath;
135140
if (!base) {

test/no-dead-link.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ tester.run('no-dead-link', rule, {
2525
text:
2626
'should be able to check relative pathes when checkRelative is true: ![robot](index.html)',
2727
options: {
28-
checkRelative: true,
2928
baseURI: 'https://example.com/',
3029
},
3130
},
@@ -36,6 +35,13 @@ tester.run('no-dead-link', rule, {
3635
ignore: ['https://example.com/404.html'],
3736
},
3837
},
38+
{
39+
text:
40+
'should ignore relative URIs when `checkRelative` is false: [test](./a.md).',
41+
options: {
42+
checkRelative: false,
43+
},
44+
},
3945
{
4046
text: fs.readFileSync(path.join(__dirname, 'fixtures/a.md'), 'utf-8'),
4147
options: {

0 commit comments

Comments
 (0)