Skip to content

Commit

Permalink
Stringify object and array responses before encoding for download. Is…
Browse files Browse the repository at this point in the history
…sue: #2187
  • Loading branch information
garethbowen committed Apr 21, 2016
1 parent 4f0a4fa commit 6af61bc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion static/js/modules/ajax-download.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var _ = require('underscore');

(function () {

'use strict';
Expand All @@ -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);
};

/**
Expand Down

0 comments on commit 6af61bc

Please sign in to comment.