From ce02b0912dc68cd4849a084d8bff26527943b6a7 Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Thu, 23 Jan 2014 08:07:46 +1100 Subject: [PATCH] Fix encoding issues, re #13 --- index.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 1ac736c..4b1c82f 100644 --- a/index.js +++ b/index.js @@ -152,13 +152,11 @@ exports.request = function (options, callback) { if (!options.encoding && options.encoding !== null) { options.encoding = 'utf8'; } - if (options.encoding) { - encoding = options.encoding; - if (encoding === 'ascii') { - options['use-ascii'] = true; - } - delete options.encoding; + encoding = options.encoding; + if (encoding === 'ascii') { + options['use-ascii'] = true; } + delete options.encoding; //Parse POST data if (options.data && typeof options.data === 'object') { @@ -388,7 +386,7 @@ exports.copy = function (obj) { var copy = {}; for (var i in obj) { if (typeof obj[i] === 'object') { - copy[i] = exports.copy(obj[i]); + copy[i] = copy[i] ? exports.copy(obj[i]) : null; } else { copy[i] = obj[i]; }