2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Moving utility functions into utils

This commit is contained in:
Matt Zabriskie
2014-08-28 12:33:53 -06:00
parent ceca9ced47
commit cec3482ff7
17 changed files with 971 additions and 647 deletions
+4 -8
View File
@@ -1,10 +1,6 @@
'use strict';
var forEach = require('./forEach');
function trim(str) {
return str.replace(/^\s*/, '').replace(/\s*$/, '');
}
var utils = require('./utils');
/**
* Parse headers into an object
@@ -24,10 +20,10 @@ module.exports = function parseHeaders(headers) {
if (!headers) return parsed;
forEach(headers.split('\n'), function(line) {
utils.forEach(headers.split('\n'), function(line) {
i = line.indexOf(':');
key = trim(line.substr(0, i)).toLowerCase();
val = trim(line.substr(i + 1));
key = utils.trim(line.substr(0, i)).toLowerCase();
val = utils.trim(line.substr(i + 1));
if (key) {
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;