openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
22 lines (21 loc) • 832 B
JavaScript
//#region packages/gateway-client/src/gateway-origin-scope.ts
function normalizeGatewayScope(e, t) {
const n = e.trim();
if (!n) return "default";
const r = globalThis.location;
const i = r ? `${r.protocol}//${r.host}${r.pathname || "/"}` : void 0;
const a = URL.parse(n, i);
if (!a) return n;
const o = a.pathname === "/" ? "" : a.pathname.replace(/\/+$/, "") || a.pathname;
return `${a.protocol}//${a.host}${o}${t ? a.search : ""}`;
}
/** Normalizes the gateway URL scope used for origin-bound device tokens. */
function gatewayOriginScope(e) {
return normalizeGatewayScope(e, false);
}
/** Normalizes the gateway URL scope used for browser credential records. */
function gatewayCredentialScope(e) {
return normalizeGatewayScope(e, true);
}
//#endregion
export { gatewayOriginScope as n, gatewayCredentialScope as t };