From d035e18b9fa91176617646ec2fd0d45a97815c0a Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 10 Dec 2017 10:05:47 +0300 Subject: [PATCH] expose responseType in download() --- js/messaging.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/messaging.js b/js/messaging.js index 1feb35be..5f1a6cf2 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -417,6 +417,7 @@ function deleteStyleSafe({id, notify = true} = {}) { function download(url, { method = url.includes('?') ? 'POST' : 'GET', body = url.includes('?') ? url.slice(url.indexOf('?')) : null, + responseType = 'text', requiredStatusCode = 200, timeout = 10e3, headers = { @@ -444,12 +445,13 @@ function download(url, { if (event.type !== 'error' && ( xhr.status === requiredStatusCode || !requiredStatusCode || url.protocol === 'file:')) { - resolve(xhr.responseText); + resolve(xhr.response); } else { reject(xhr.status); } }; xhr.onerror = xhr.onloadend; + xhr.responseType = responseType; xhr.open(method, url.href, true); for (const key in headers) { xhr.setRequestHeader(key, headers[key]);