Update MD034/no-bare-urls to allow quoting bare URLs.

This commit is contained in:
David Anson 2020-04-08 21:58:52 -07:00
parent e319f9501c
commit 320acfd7cc
4 changed files with 28 additions and 5 deletions

View file

@ -24,10 +24,14 @@ module.exports = {
const matchIndex = match.index;
const bareUrlLength = bareUrl.length;
// Allow "[https://example.com]" to avoid conflicts with
// MD011/no-reversed-links
// MD011/no-reversed-links; allow quoting as another way
// of deliberately including a bare URL
const leftChar = content[matchIndex - 1];
const rightChar = content[matchIndex + bareUrlLength];
if (
(content[matchIndex - 1] !== "[") ||
(content[matchIndex + bareUrlLength] !== "]")
!((leftChar === "[") && (rightChar === "]")) &&
!((leftChar === "\"") && (rightChar === "\"")) &&
!((leftChar === "'") && (rightChar === "'"))
) {
const index = line.indexOf(content);
const range = (index === -1) ? null : [