UNPKG

916 BJavaScriptView Raw
1/*
2 * Copyright 2012 the original author or authors
3 * @license MIT, see LICENSE.txt for details
4 *
5 * @author Scott Andrews
6 */
7
8(function (define) {
9 'use strict';
10
11 define(function (/* require */) {
12
13 /**
14 * Normalize HTTP header names using the pseudo camel case.
15 *
16 * For example:
17 * content-type -> Content-Type
18 * accepts -> Accepts
19 * x-custom-header-name -> X-Custom-Header-Name
20 *
21 * @param {string} name the raw header name
22 * @return {string} the normalized header name
23 */
24 function normalizeHeaderName(name) {
25 return name.toLowerCase()
26 .split('-')
27 .map(function (chunk) { return chunk.charAt(0).toUpperCase() + chunk.slice(1); })
28 .join('-');
29 }
30
31 return normalizeHeaderName;
32
33 });
34
35}(
36 typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
37 // Boilerplate for AMD and Node
38));