@itxch/contentful-import
Version:
This tool allows you to import JSON dump exported by contentful-export
23 lines (22 loc) • 650 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
function getHeadersConfig(value) {
if (!value) {
return {};
}
const values = Array.isArray(value) ? value : [value];
return values.reduce((headers, value2) => {
value2 = value2.trim();
const separatorIndex = value2.indexOf(":");
if (separatorIndex === -1) {
return headers;
}
const headerKey = value2.slice(0, separatorIndex).trim();
const headerValue = value2.slice(separatorIndex + 1).trim();
return {
...headers,
[headerKey]: headerValue
};
}, {});
}
exports.getHeadersConfig = getHeadersConfig;