Skip to content

Commit

Permalink
Fix Content-Disposition parser and close ElemeFE#30
Browse files Browse the repository at this point in the history
  • Loading branch information
lujjjh committed Feb 7, 2018
1 parent 68f3c76 commit df8c757
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions faas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<script src="https://shadow.elemecdn.com/gh/codemirror/[email protected]/mode/javascript/javascript.min.js"></script>
<script src="https://shadow.elemecdn.com/gh/codemirror/[email protected]/addon/display/autorefresh.min.js"></script>
<script src="https://shadow.elemecdn.com/npm/[email protected]/index.js"></script>
<script src="https://shadow.elemecdn.com/npm/[email protected]/build@module=ContentDispositionAttachment&amp;format=umd!toes5!uglifyjs!index.js"></script>
<script extract>
class Configuration {
static get watchList() {
Expand Down Expand Up @@ -285,9 +286,12 @@
let javascript = /javascript/.test(contentType);
let binary = !(/text/.test(contentType) || json || javascript);
let contentDisposition = response.headers.get('Content-Disposition') || '';
let attachment = /attachment/.test(contentDisposition);
let filename = /filename="([^"]+)/.exec(contentDisposition);
if (filename) filename = filename[1];
try {
contentDisposition = ContentDispositionAttachment.parse(contentDisposition);
} catch (error) {
contentDisposition = { attachment: false };
}
let { attachment, filename } = contentDisposition;
let $body;
if (binary || attachment) {
$body = response.blob().then(URL.createObjectURL).then(url => {
Expand Down

0 comments on commit df8c757

Please sign in to comment.