feat(capture): add minimal browser extension

This commit is contained in:
cesnimda
2026-08-31 22:16:16 +02:00
parent b7029faaec
commit caf486dceb
5 changed files with 95 additions and 0 deletions
@@ -0,0 +1,23 @@
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"
);
});