Server address handling. Every client connects to a user-operated server, so the API base URL is runtime data that must be validated before use.
// Source: https://github.com/DEEIX-AI/DEEIX-Chat | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// Server address handling. Every client connects to a user-operated server, so
// the API base URL is runtime data that must be validated before use.
const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
/** Drop trailing slashes in linear time (a `/\/+$/` regex backtracks quadratically). */
function trimTrailingSlashes(value: string): string {
let end = value.length;
while (end > 0 && value.charCodeAt(end - 1) === 47) {
end -= 1;
}
return value.slice(0, end);
}
const DEFAULT_DEV_API_PORT = "8080";
// Strict absolute http(s) URL: scheme, host (DNS
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key