import assert from "node:assert/strict"; import test from "node:test"; import { buildCaptureUrl } from "../capture-url.mjs"; test("builds the existing reviewed capture route", () => { const result = new URL(buildCaptureUrl("https://example.test/jobs/42?from=search")); assert.equal(result.origin, "https://jobs.cesnimda.uk"); assert.equal(result.pathname, "/"); assert.equal(result.searchParams.get("add"), "https://example.test/jobs/42?from=search"); }); test("rejects privileged and malformed URLs", () => { assert.equal(buildCaptureUrl("chrome://settings"), null); assert.equal(buildCaptureUrl("javascript:alert(1)"), null); assert.equal(buildCaptureUrl("not a url"), null); }); test("supports a local application origin during development", () => { assert.equal( buildCaptureUrl("https://arbeidsplassen.nav.no/stillinger/stilling/abc", "http://localhost:3300"), "http://localhost:3300/?add=https%3A%2F%2Farbeidsplassen.nav.no%2Fstillinger%2Fstilling%2Fabc" ); });