MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / parseHeaders

Function parseHeaders

lib/test/angular/1.7.0/angular.js:11478–11499  ·  view source on GitHub ↗

* Parse headers into key value object * * @param {string} headers Raw headers as a string * @returns {Object} Parsed headers as key value object

(headers)

Source from the content-addressed store, hash-verified

11476 * @returns {Object} Parsed headers as key value object
11477 */
11478function parseHeaders(headers) {
11479 var parsed = createMap(), i;
11480
11481 function fillInParsed(key, val) {
11482 if (key) {
11483 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
11484 }
11485 }
11486
11487 if (isString(headers)) {
11488 forEach(headers.split('\n'), function(line) {
11489 i = line.indexOf(':');
11490 fillInParsed(lowercase(trim(line.substr(0, i))), trim(line.substr(i + 1)));
11491 });
11492 } else if (isObject(headers)) {
11493 forEach(headers, function(headerVal, headerKey) {
11494 fillInParsed(lowercase(headerKey), trim(headerVal));
11495 });
11496 }
11497
11498 return parsed;
11499}
11500
11501
11502/**

Callers 2

headersGetterFunction · 0.70
doneFunction · 0.70

Calls 7

createMapFunction · 0.70
isStringFunction · 0.70
forEachFunction · 0.70
fillInParsedFunction · 0.70
lowercaseFunction · 0.70
trimFunction · 0.70
isObjectFunction · 0.70

Tested by

no test coverage detected