openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 894 B
JavaScript
import{l as normalizeOptionalString,o as normalizeLowercaseStringOrEmpty}from"./string-coerce-CpTFcSwY.mjs";
//!src/gateway/http-header-value.ts
function firstHeaderValue(e){return Array.isArray(e)?e[0]:e}function getHeader(e,t){return firstHeaderValue(e.headers[normalizeLowercaseStringOrEmpty(t)])}function getBearerToken(e){const t=normalizeOptionalString(getHeader(e,`authorization`))??``;if(!normalizeLowercaseStringOrEmpty(t).startsWith(`bearer `))return;return normalizeOptionalString(t.slice(7))}function splitHttpHeaderValue(e,t,n){const r=[];let i=0;let a=false;let o=false;for(let s=0;s<e.length;s+=1){const c=e[s];if(o)o=false;else if(a&&n===`quoted-string`&&c===`\\`)o=true;else if(c===`"`)a=!a;else if(!a&&c===t){r.push(e.slice(i,s));i=s+1}}if(a||o)return null;r.push(e.slice(i));return r}export{splitHttpHeaderValue as i,getBearerToken as n,getHeader as r,firstHeaderValue as t};