2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +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
+6 -6
View File
@@ -1,6 +1,6 @@
'use strict';
var forEach = require('./forEach');
var utils = require('./utils');
function encode(val) {
return encodeURIComponent(val).
@@ -18,19 +18,19 @@ module.exports = function buildUrl(url, params) {
var parts = [];
forEach(params, function (val, key) {
utils.forEach(params, function (val, key) {
if (val === null || typeof val === 'undefined') {
return;
}
if (Object.prototype.toString.call(val) !== '[object Array]') {
if (!utils.isArray(val)) {
val = [val];
}
forEach(val, function (v) {
if (Object.prototype.toString.call(v) === '[object Date]') {
utils.forEach(val, function (v) {
if (utils.isDate(v)) {
v = v.toISOString();
}
else if (typeof v === 'object') {
else if (utils.isObject(v)) {
v = JSON.stringify(v);
}
parts.push(encode(key) + '=' + encode(v));