Files
t3code/apps/server/src/http.test.ts
T
b7559c4678 Implement server auth bootstrap and pairing flow (#1768)
Co-authored-by: codex <[email protected]>
Co-authored-by: Julius Marminge <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
2026-04-09 10:18:30 -07:00

28 lines
1023 B
TypeScript

import { describe, expect, it } from "vitest";
import { isLoopbackHostname, resolveDevRedirectUrl } from "./http.ts";
describe("http dev routing", () => {
it("treats localhost and loopback addresses as local", () => {
expect(isLoopbackHostname("127.0.0.1")).toBe(true);
expect(isLoopbackHostname("localhost")).toBe(true);
expect(isLoopbackHostname("::1")).toBe(true);
expect(isLoopbackHostname("[::1]")).toBe(true);
});
it("does not treat LAN addresses as local", () => {
expect(isLoopbackHostname("192.168.86.35")).toBe(false);
expect(isLoopbackHostname("10.0.0.24")).toBe(false);
expect(isLoopbackHostname("example.local")).toBe(false);
});
it("preserves path and query when redirecting to the dev server", () => {
const devUrl = new URL("http://127.0.0.1:5173/");
const requestUrl = new URL("http://127.0.0.1:3774/pair?token=test-token");
expect(resolveDevRedirectUrl(devUrl, requestUrl)).toBe(
"http://127.0.0.1:5173/pair?token=test-token",
);
});
});