Download cloud-v2/packages/cli/src/config.test.ts from Anirudh1950/MentraOS: direct link, hf CLI and curl.
- Browser
- Download file 952 Bytes
-
https://huggingface.co/Anirudh1950/MentraOS/resolve/main/cloud-v2/packages/cli/src/config.test.ts
- Command line
-
hf download hf://Anirudh1950/MentraOS/cloud-v2/packages/cli/src/config.test.ts
-
curl -L -o config.test.ts https://huggingface.co/Anirudh1950/MentraOS/resolve/main/cloud-v2/packages/cli/src/config.test.ts
952 Bytes
| import {expect, test} from "bun:test" | |
| import {isLoopbackHttp, normalizeUrl} from "./config" | |
| test("plain HTTP is accepted only to this machine: 127.0.0.1, localhost and [::1]", () => { | |
| // The URL parser keeps an IPv6 hostname's brackets, so "[::1]" is what the check sees. | |
| expect(new URL("http://[::1]:3003/").hostname).toBe("[::1]") | |
| for (const url of ["http://127.0.0.1:3003", "http://localhost:3003", "http://[::1]:3003"]) { | |
| expect(isLoopbackHttp(new URL(url))).toBe(true) | |
| expect(normalizeUrl(`${url}/`, "MENTRA_CORE_URL")).toBe(url) | |
| } | |
| for (const url of ["http://[::2]:3003", "http://127.0.0.2:3003", "http://core.example", "http://localhost.example"]) { | |
| expect(isLoopbackHttp(new URL(url))).toBe(false) | |
| expect(() => normalizeUrl(url, "MENTRA_CORE_URL")).toThrow("must be an HTTPS URL") | |
| } | |
| expect(normalizeUrl("https://core.mentraglass.com/", "MENTRA_CORE_URL")).toBe("https://core.mentraglass.com") | |
| }) | |