mirror of
https://github.com/theoludwig/markdownlint-rule-relative-links.git
synced 2024-11-04 18:21:31 +01:00
fix: ignore absolute paths /absolute/path
This commit is contained in:
parent
77b8988bea
commit
c985af6156
@ -71,7 +71,8 @@ const customRule = {
|
|||||||
if (hrefSrc != null) {
|
if (hrefSrc != null) {
|
||||||
const url = new URL(hrefSrc, pathToFileURL(params.name))
|
const url = new URL(hrefSrc, pathToFileURL(params.name))
|
||||||
url.hash = ''
|
url.hash = ''
|
||||||
const isRelative = url.protocol === 'file:'
|
const isRelative =
|
||||||
|
url.protocol === 'file:' && !hrefSrc.startsWith('/')
|
||||||
if (isRelative && !fs.existsSync(url)) {
|
if (isRelative && !fs.existsSync(url)) {
|
||||||
const detail = `Link "${hrefSrc}" is dead`
|
const detail = `Link "${hrefSrc}" is dead`
|
||||||
addError(onError, lineNumber, detail)
|
addError(onError, lineNumber, detail)
|
||||||
|
2
test/fixtures/Valid.md
vendored
2
test/fixtures/Valid.md
vendored
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
![Image](./image.png)
|
![Image](./image.png)
|
||||||
|
|
||||||
|
![Absolute Path](/absolute/path.png)
|
||||||
|
|
||||||
[External https link](https://example.com/)
|
[External https link](https://example.com/)
|
||||||
|
|
||||||
[External https link 2](https:./external.https)
|
[External https link 2](https:./external.https)
|
||||||
|
Loading…
Reference in New Issue
Block a user