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