rest-template
Version:
HTTP client library inspired by the Spring Framework's RestTemplate
36 lines (29 loc) • 825 B
JavaScript
(function (define) {
define([], function () {
"use strict";
var re = /^[a-z]|-[a-z]/g;
/**
* Normalize HTTP header names using the pseudo camel case.
*
* For example:
* content-type -> Content-Type
* accepts -> Accepts
* x-custom-header-name -> X-Custom-Header-Name
*
* @param {String} name the raw header name
* @return {String} the normalized header name
*/
function normalizeHeaderName(name) {
return name.toLowerCase()
.split('-')
.map(function (chunk) { return chunk.charAt(0).toUpperCase() + chunk.slice(1); })
.join('-');
}
return normalizeHeaderName;
});
}(
typeof define === 'function' ? define : function (deps, factory) {
module.exports = factory.apply(this, deps.map(require));
}
// Boilerplate for AMD and Node
));