import { test } from "node:test"; import assert from "node:assert/strict"; import { extractUrls, hostOf, classifyUnverifiable } from "../check-links.mjs"; test("check_links_extracts_markdown_and_bare_urls", () => { const md = "See [Rule](https://babaiswiki.fandom.com/wiki/Rule). Also https://example.com/a, and " + "(https://en.wikipedia.org/wiki/Foo_(bar)) and `https://x.org/y`."; assert.deepEqual(extractUrls(md), [ "https://babaiswiki.fandom.com/wiki/Rule", "https://example.com/a", "https://en.wikipedia.org/wiki/Foo_(bar)", "https://x.org/y", ]); }); test("check_links_reports_malformed_urls_instead_of_throwing", () => { // `new URL()` throws on these; the checker must still finish and exit 0. assert.equal(hostOf("http://[bad"), null); assert.equal(classifyUnverifiable("http://[bad"), "invalid URL"); assert.equal(classifyUnverifiable("https://www.reddit.com/r/x").startsWith("unverifiable"), true); assert.equal(classifyUnverifiable("https://example.com/a"), null); });