Skip to content

Commit

Permalink
download filename fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabricio872 committed Nov 7, 2024
1 parent 55356e5 commit 9150fec
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions assets/vue/controllers/Page/CustomizerPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,19 @@ export default {
);
const url = window.URL.createObjectURL(new Blob([response.data]));
let filename = '';
const contentDisposition = response.headers['content-disposition'];
if (contentDisposition) {
const filenameMatch = contentDisposition.match(/filename="(.+)"/);
if (filenameMatch.length > 1) {
filename = filenameMatch[1];
}
}
const link = document.createElement('a');
link.href = url;
if (identifier === 'variables') {
link.setAttribute('download', `${identifier}.scss`);
} else {
link.setAttribute('download', `${identifier}.css`);
}
link.setAttribute('download', filename);
document.body.appendChild(link);
link.click();
link.remove();
Expand Down

0 comments on commit 9150fec

Please sign in to comment.