Restrict external browser URLs

This commit is contained in:
ZacharyZhang-NY committed 2026-06-26 19:37:11 -04:00
1 parent d148146b91
commit 91991f7c4a
3 files changed
+25 -7

No files matched your search

@@ -0,0 +1,14 @@
import { describe, expect, test } from "vitest";
import { normalizeExternalBrowserUrl } from "../../src/main/app/external-url";
describe("external browser URL validation", () => {
test("normalizes HTTPS URLs and preserves query strings", () => {
expect(normalizeExternalBrowserUrl("https://example.com/docs?q=agent")).toBe("https://example.com/docs?q=agent");
});
test("rejects non-HTTPS and credential-bearing URLs", () => {
expect(() => normalizeExternalBrowserUrl("http://example.com")).toThrow("External URLs must use HTTPS.");
expect(() => normalizeExternalBrowserUrl("mailto:security@example.com")).toThrow("External URLs must use HTTPS.");
expect(() => normalizeExternalBrowserUrl("https://user:token@example.com")).toThrow("External URLs must not include credentials.");
});
});