From c985af6156d76e7761eabab8d22eee2e49509e84 Mon Sep 17 00:00:00 2001 From: Divlo Date: Sun, 2 Apr 2023 21:10:47 +0200 Subject: [PATCH] fix: ignore absolute paths `/absolute/path` --- src/index.js | 3 ++- test/fixtures/Valid.md | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 99b09be..4de3307 100644 --- a/src/index.js +++ b/src/index.js @@ -71,7 +71,8 @@ const customRule = { if (hrefSrc != null) { const url = new URL(hrefSrc, pathToFileURL(params.name)) url.hash = '' - const isRelative = url.protocol === 'file:' + const isRelative = + url.protocol === 'file:' && !hrefSrc.startsWith('/') if (isRelative && !fs.existsSync(url)) { const detail = `Link "${hrefSrc}" is dead` addError(onError, lineNumber, detail) diff --git a/test/fixtures/Valid.md b/test/fixtures/Valid.md index 35fa567..327d56a 100644 --- a/test/fixtures/Valid.md +++ b/test/fixtures/Valid.md @@ -4,6 +4,8 @@ ![Image](./image.png) +![Absolute Path](/absolute/path.png) + [External https link](https://example.com/) [External https link 2](https:./external.https)