feat: validate link in image src

This commit is contained in:
Divlo
2023-01-02 19:45:46 +01:00
parent 4adef29333
commit 5dab1976d3
5 changed files with 43 additions and 14 deletions

View File

@ -12,13 +12,23 @@ tap.test('ensure we validate correctly', async (t) => {
customRules: [relativeLinks]
})
t.equal(lintResults['test/fixtures/Valid.md'].length, 0)
t.equal(lintResults['test/fixtures/Invalid.md'].length, 1)
t.equal(lintResults['test/fixtures/Invalid.md'].length, 2)
t.equal(
lintResults['test/fixtures/Invalid.md'][0].ruleDescription,
lintResults['test/fixtures/Invalid.md'][0]?.ruleDescription,
'Relative links should be valid'
)
t.equal(
lintResults['test/fixtures/Invalid.md'][0].errorDetail,
lintResults['test/fixtures/Invalid.md'][0]?.errorDetail,
'Link "./basic.test.js" is dead'
)
t.equal(
lintResults['test/fixtures/Invalid.md'][1]?.ruleDescription,
'Relative links should be valid'
)
t.equal(
lintResults['test/fixtures/Invalid.md'][1]?.errorDetail,
'Link "../image.png" is dead'
)
})

View File

@ -1,3 +1,5 @@
# Invalid
[basic.js](./basic.test.js)
![Image](../image.png)

View File

@ -1,3 +1,5 @@
# Valid
[basic.js](../basic.test.js)
![Image](./image.png)

BIN
test/fixtures/image.png vendored Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B