Rename helpers.bareUrlRe to urlRe, improve it a little, add tests

This commit is contained in:
David Anson 2022-12-15 13:54:54 -08:00
parent 6e38259a4a
commit 2e2937081e
5 changed files with 103 additions and 16 deletions

View file

@ -2,9 +2,8 @@
"use strict";
const { addErrorDetailIf, bareUrlRe, escapeForRegExp, forEachLine,
forEachLink, withinAnyRange, linkReferenceDefinitionRe } =
require("../helpers");
const { addErrorDetailIf, escapeForRegExp, forEachLine, forEachLink,
linkReferenceDefinitionRe, urlRe, withinAnyRange } = require("../helpers");
const { codeBlockAndSpanRanges, htmlElementRanges, lineMetadata } =
require("./cache");
@ -28,7 +27,7 @@ module.exports = {
exclusions.push([ lineIndex, 0, line.length ]);
} else {
let match = null;
while ((match = bareUrlRe.exec(line)) !== null) {
while ((match = urlRe.exec(line)) !== null) {
exclusions.push([ lineIndex, match.index, match[0].length ]);
}
forEachLink(line, (index, _, text, destination) => {