import { describe, expect, it } from "vitest"; import { resolveConfig } from "#lib/server/config.ts"; const fosterKnotUrl = (foster?: string) => resolveConfig({ FOSTER_KNOT_URL: foster }).fosterKnotUrl; describe("resolveConfig fosterKnotUrl", () => { it("parses a bare-origin url into the knot origin, ignoring a trailing slash", () => { expect(fosterKnotUrl("https://foster.test")).toBe("foster.test"); expect(fosterKnotUrl("https://foster.test/")).toBe("foster.test"); expect(fosterKnotUrl("http://127.0.0.1:5555")).toBe("127.0.0.1:5555"); }); it("is empty when unset or blank", () => { expect(fosterKnotUrl()).toBe(""); expect(fosterKnotUrl(" ")).toBe(""); }); it.each(["https://foster.test/foster", "foster.test"])( "rejects %s at config load instead of quietly routing reads to the origin", (url) => { expect(() => fosterKnotUrl(url)).toThrow(/FOSTER_KNOT_URL/); } ); });