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:
+4
-8
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user