From 18b04408e1d07fa162db92fa30eec77adfeb0e44 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 29 Jan 2016 23:53:30 -0500 Subject: [PATCH] update text parsing --- apiclient.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apiclient.js b/apiclient.js index 5c64655..690e246 100644 --- a/apiclient.js +++ b/apiclient.js @@ -275,7 +275,7 @@ if (request.dataType == 'json' || request.headers.accept == 'application/json') { return response.json(); - } else if ((response.headers.get('Content-Type') || '').toLowerCase().indexOf('text/') == 0) { + } else if (request.dataType == 'text' || (response.headers.get('Content-Type') || '').toLowerCase().indexOf('text/') == 0) { return response.text(); } else { return response; @@ -400,7 +400,7 @@ if (request.dataType == 'json' || request.headers.accept == 'application/json') { return response.json(); - } else if ((response.headers.get('Content-Type') || '').toLowerCase().indexOf('text/') == 0) { + } else if (request.dataType == 'text' || (response.headers.get('Content-Type') || '').toLowerCase().indexOf('text/') == 0) { return response.text(); } else { return response; @@ -1304,6 +1304,9 @@ if (!path) { throw new Error("null path"); } + if (typeof (path) !== 'string') { + throw new Error('invalid path'); + } options = options || {}; @@ -1347,7 +1350,8 @@ return self.ajax({ type: "GET", - url: url + url: url, + dataType: 'text' }); };