refactor(models): share auth helpers and forward-compat list fallbacks

This commit is contained in:
Peter Steinberger
2026-02-14 01:07:19 +01:00
parent 363a56ab87
commit cf2524b8b9
8 changed files with 175 additions and 233 deletions

View File

@@ -43,6 +43,22 @@ export const formatMs = (value?: number | null) => {
return `${Math.round(value / 100) / 10}s`;
};
export const isLocalBaseUrl = (baseUrl: string) => {
try {
const url = new URL(baseUrl);
const host = url.hostname.toLowerCase();
return (
host === "localhost" ||
host === "127.0.0.1" ||
host === "0.0.0.0" ||
host === "::1" ||
host.endsWith(".local")
);
} catch {
return false;
}
};
export async function updateConfig(
mutator: (cfg: OpenClawConfig) => OpenClawConfig,
): Promise<OpenClawConfig> {