UNPKG

@baqhub/sdk

Version:

The official JavaScript SDK for the BAQ federated app platform.

23 lines (22 loc) 638 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpHeader = void 0; const parseHeaderRegexp = /(?:^|\s+)([\w]+)="([^"]+)"/g; function parseHeader(value) { return [...value.matchAll(parseHeaderRegexp)].reduce((result, match) => { if (!match || !match[1] || !match[2]) { return result; } result[match[1]] = match[2]; return result; }, {}); } function headerToString(value) { return Object.entries(value) .map(([k, v]) => `${k}="${v}"`) .join(" "); } exports.HttpHeader = { parse: parseHeader, toString: headerToString, };