Fix Issue #1991 filename parameter in content disposition response header
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user