openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
20 lines (19 loc) • 921 B
JavaScript
import { t as resolveGatewayPublicOrigin } from "./gateway-public-origin-SLjx6A2a.mjs";
//#region src/gateway/control-ui-shared.ts
/** Normalizes a Control UI base path to either "" or a leading-slash path without trailing slash. */
function normalizeControlUiBasePath(e) {
const t = e?.trim() ?? "";
if (!t || t === "/") return "";
const n = t.startsWith("/") ? t : `/${t}`;
return n.endsWith("/") ? n.slice(0, -1) : n;
}
/** Keeps push navigation in the receiving PWA while selecting its originating Gateway. */
function resolveControlUiWebPushUrl(e, t) {
const n = resolveGatewayPublicOrigin(e);
if (!n) return t;
const r = normalizeControlUiBasePath(e.gateway?.controlUi?.basePath);
const i = `${n.replace(/^https:/u, "wss:").replace(/^http:/u, "ws:")}${r}`;
return `${t}#${new URLSearchParams({ gatewayUrl: i })}`;
}
//#endregion
export { resolveControlUiWebPushUrl as n, normalizeControlUiBasePath as t };