Skip to content

Commit

Permalink
Fix Issue swagger-api#1991 filename parameter in content disposition …
Browse files Browse the repository at this point in the history
…response header
  • Loading branch information
davehagler committed Feb 24, 2016
1 parent 0d0864f commit 5809c87
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/javascript/view/OperationView.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,15 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
var fileName = response.url.substr(response.url.lastIndexOf('/') + 1);
var download = [type, fileName, href].join(':');

// Use filename from response header
var disposition = headers['content-disposition'] || headers['Content-Disposition'];
if(typeof disposition !== 'undefined') {
var responseFilename = /filename=([^;]*);?/.exec(disposition);
if(responseFilename != null && responseFilename.length > 1) {
download = responseFilename[1];
}
}

a.setAttribute('href', href);
a.setAttribute('download', download);
a.innerText = 'Download ' + fileName;
Expand Down

0 comments on commit 5809c87

Please sign in to comment.