Files
musistudio--claude-code-router/tests/main/web-management-server.test.mjs
T
wehub-resource-sync 9f48d4a18c
Docs / Build (push) Has been cancelled
Docs / Deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:37:25 +08:00

15 lines
948 B
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { normalizeExternalHttpTarget } from "../../packages/core/src/web/management-server.ts";
test("normalizeExternalHttpTarget only accepts absolute http and https URLs", () => {
assert.equal(normalizeExternalHttpTarget(""), undefined);
assert.equal(normalizeExternalHttpTarget(undefined), undefined);
assert.equal(normalizeExternalHttpTarget("about:blank"), undefined);
assert.equal(normalizeExternalHttpTarget(" https://example.com/path?q=1 "), "https://example.com/path?q=1");
assert.equal(normalizeExternalHttpTarget("http://localhost:3458/"), "http://localhost:3458/");
assert.throws(() => normalizeExternalHttpTarget("file:///etc/passwd"), /Only http and https/);
assert.throws(() => normalizeExternalHttpTarget("javascript:alert(1)"), /Only http and https/);
assert.throws(() => normalizeExternalHttpTarget("example.com"), /valid absolute URL/);
});