From 6af61bc53798d05506a1fb0614b3bed5edf3fc61 Mon Sep 17 00:00:00 2001 From: Gareth Bowen Date: Tue, 12 Apr 2016 22:57:23 +1200 Subject: [PATCH] Stringify object and array responses before encoding for download. Issue: #2187 --- static/js/modules/ajax-download.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/static/js/modules/ajax-download.js b/static/js/modules/ajax-download.js index dd858670abb..380b1a5717a 100644 --- a/static/js/modules/ajax-download.js +++ b/static/js/modules/ajax-download.js @@ -1,3 +1,5 @@ +var _ = require('underscore'); + (function () { 'use strict'; @@ -15,8 +17,12 @@ }; var getHref = function(res) { + var data = res.data; + if (!_.isString(data)) { + data = JSON.stringify(data); + } var mimetype = res.headers('Content-Type'); - return 'data:' + mimetype + ',' + encodeURIComponent(res.data); + return 'data:' + mimetype + ',' + encodeURIComponent(data); }; /**