Merge pull request #59 from h44z/download-filename

Sanitize download filename
This commit is contained in:
vx3r 2020-11-12 15:19:06 +01:00 committed by GitHub
commit b3af5bcfb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -601,10 +601,17 @@
const url = window.URL.createObjectURL(new Blob([config]))
const link = document.createElement('a')
link.href = url
link.setAttribute('download', client.name.split(' ').join('-') + '.conf') //or any other extension
link.setAttribute('download', this.getConfigFileName(client)) //or any other extension
document.body.appendChild(link)
link.click()
},

getConfigFileName(client){
let name = client.name.split(' ').join('-');
// replace special chars
name = name.replace(/[^a-zA-Z0-9_-]+/g, '');
return name + '.conf';
},
}
};
</script>