diff --git a/lib/rules.js b/lib/rules.js index 6f9888b7..cf09ff9e 100644 --- a/lib/rules.js +++ b/lib/rules.js @@ -1126,17 +1126,19 @@ module.exports = [ var names = params.options.names || []; names.forEach(function forName(name) { var escapedName = escapeForRegExp(name); - var namePattern = "\\b" + escapedName + "\\b"; + var namePattern = "\\S*\\b(" + escapedName + ")\\b\\S*"; var anyNameRe = new RegExp(namePattern, "gi"); function forToken(token) { var fenceOffset = (token.type === "fence") ? 1 : 0; token.content.split(shared.newLineRe) .forEach(function forLine(line, index) { - var matches = line.match(anyNameRe) || []; - matches.forEach(function forMatch(match) { - var lineNumber = token.lineNumber + index + fenceOffset; - errors.addDetailIf(lineNumber, name, match); - }); + var match = null; + while ((match = anyNameRe.exec(line)) !== null) { + if (!bareUrlRe.test(match[0])) { + var lineNumber = token.lineNumber + index + fenceOffset; + errors.addDetailIf(lineNumber, name, match[1]); + } + } }); } forEachInlineChild(params, "text", forToken); diff --git a/test/proper-names.md b/test/proper-names.md index eb31d2ae..6e651633 100644 --- a/test/proper-names.md +++ b/test/proper-names.md @@ -58,7 +58,7 @@ Link to [GitHub](https://github.com/). Link to [markdownlint](https://github.com/DavidAnson/MARKDOWNLINT). -Bare URL https://github.com/DavidAnson/markdownlint {MD034} {MD044} +Bare URL exempt https://github.com/DavidAnson/MARKDOWNLINT {MD034} A short paragraph about node.js and {MD044}