1

Corrige les faux positifs dans l'analyse des liens Markdown

This commit is contained in:
2026-03-25 23:06:33 +01:00
parent 3cb735333a
commit a2cbaeacd1
2 changed files with 179 additions and 8 deletions

View File

@@ -15,6 +15,12 @@ test("extractLinksFromText returns sanitized external URLs only once", () => {
assert.deepStrictEqual(urls, ["https://example.com", "https://foo.com", "https://bar.com/path"]);
});
test("extractLinksFromText does not extend a markdown destination past the closing parenthesis", () => {
const input = "J'ai eu mon lot d'installations du couple [anope](https://www.anope.org/)/epona.";
const urls = extractLinksFromText(input);
assert.deepStrictEqual(urls, ["https://www.anope.org/"]);
});
test("collectMarkdownLinksFromStream preserves line numbers", async () => {
const content = [
"Intro line with no link",
@@ -41,6 +47,27 @@ test("collectMarkdownLinksFromStream preserves line numbers", async () => {
]);
});
test("collectMarkdownLinksFromStream ignores inline code, fenced code blocks and indented code blocks", async () => {
const content = [
"Visible https://visible.example.com.",
"Inline code `https://inline.example.com` and normal https://normal.example.com.",
"",
"```yaml",
"uses: https://github.com/easingthemes/ssh-deploy@main",
"```",
"",
" https://indented.example.com",
"After code https://after.example.com.",
].join("\n");
const stream = Readable.from([content]);
const links = await collectMarkdownLinksFromStream(stream);
assert.deepStrictEqual(links, [
{ url: "https://visible.example.com", line: 1 },
{ url: "https://normal.example.com", line: 2 },
{ url: "https://after.example.com", line: 9 },
]);
});
test("collectMarkdownLinksFromStream ignores URLs in front matter entirely", async () => {
const content = [
"---",