diff --git a/lib/md033.js b/lib/md033.js index 6d0a2e0e..dbe14d76 100644 --- a/lib/md033.js +++ b/lib/md033.js @@ -2,8 +2,7 @@ "use strict"; -const { addError, bareUrlRe, forEachLine, unescapeMarkdown } = - require("../helpers"); +const { addError, forEachLine, unescapeMarkdown } = require("../helpers"); const { lineMetadata } = require("./cache"); const htmlElementRe = /<(([A-Za-z][A-Za-z0-9-]*)(?:\s[^>]*)?)\/?>/g; @@ -24,10 +23,10 @@ module.exports = { forEachLine(lineMetadata(), (line, lineIndex, inCode) => { let match = null; // eslint-disable-next-line no-unmodified-loop-condition - while (!inCode && (match = htmlElementRe.exec(line))) { + while (!inCode && ((match = htmlElementRe.exec(line)) !== null)) { const [ tag, content, element ] = match; if (!allowedElements.includes(element.toLowerCase()) && - !tag.endsWith("\\>") && !bareUrlRe.test(content) && + !tag.endsWith("\\>") && !emailAddressRe.test(content)) { const prefix = line.substring(0, match.index); if (!linkDestinationRe.test(prefix) && !inlineCodeRe.test(prefix)) { diff --git a/lib/md044.js b/lib/md044.js index ff0974a5..181f20cf 100644 --- a/lib/md044.js +++ b/lib/md044.js @@ -24,7 +24,7 @@ module.exports = { let match = null; while ((match = anyNameRe.exec(line)) !== null) { const fullMatch = match[0]; - if (!bareUrlRe.test(fullMatch)) { + if (fullMatch.search(bareUrlRe) === -1) { const wordMatch = fullMatch .replace(/^\W*/, "").replace(/\W*$/, ""); if (!names.includes(wordMatch)) { diff --git a/test/proper-names-urls.json b/test/proper-names-urls.json new file mode 100644 index 00000000..7852d907 --- /dev/null +++ b/test/proper-names-urls.json @@ -0,0 +1,14 @@ +{ + "default": true, + "proper-names": { + "names": [ + "HTTPS", + "EXAMPLE", + "COM", + "DIRECTORY", + "FILE" + ] + }, + "no-bare-urls": false, + "code-block-style": false +} diff --git a/test/proper-names-urls.md b/test/proper-names-urls.md new file mode 100644 index 00000000..0522e9d1 --- /dev/null +++ b/test/proper-names-urls.md @@ -0,0 +1,33 @@ +# Proper Names in URLs + +Text https text {MD044} +Text example text {MD044} +Text com text {MD044} +Text directory text {MD044} +Text file text {MD044} +Text HTTPS EXAMPLE COM DIRECTORY FILE text + +> The following lines are deliberately duplicated + +Text https://example.com/directory/file text + +Text https://example.com/directory/file text + +Text text + +Text text + +Text [https://example.com/directory/file](https://example.com/directory/file) text + +Text [https://example.com/directory/file](https://example.com/directory/file) text + +Text `https://example.com/directory/file` text +Text `https://example.com/directory/file` text + +```text +Text https://example.com/directory/file text +Text https://example.com/directory/file text +``` + + Text https://example.com/directory/file text + Text https://example.com/directory/file text