openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
2 lines • 582 B
JavaScript
//!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:``}`}function gatewayOriginScope(e){return normalizeGatewayScope(e,false)}function gatewayCredentialScope(e){return normalizeGatewayScope(e,true)}export{gatewayOriginScope as n,gatewayCredentialScope as t};