Remove characters from the name of the config-file that prevent it from being imported into WireGuard apps

This commit is contained in:
Christoph Haas 2020-10-08 10:41:57 +02:00
parent 8b4038c238
commit aa71b15d72
1 changed files with 8 additions and 1 deletions

View File

@ -601,10 +601,17 @@
const url = window.URL.createObjectURL(new Blob([config])) const url = window.URL.createObjectURL(new Blob([config]))
const link = document.createElement('a') const link = document.createElement('a')
link.href = url 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) document.body.appendChild(link)
link.click() 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> </script>