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' }); };