From aa71b15d72b76ea43b22ddf00ef8006f9dfdcb43 Mon Sep 17 00:00:00 2001
From: Christoph Haas <christoph.h@sprinternet.at>
Date: Thu, 8 Oct 2020 10:41:57 +0200
Subject: [PATCH] Remove characters from the name of the config-file that
 prevent it from being imported into WireGuard apps

---
 ui/src/components/Clients.vue | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ui/src/components/Clients.vue b/ui/src/components/Clients.vue
index b06e238..305e695 100644
--- a/ui/src/components/Clients.vue
+++ b/ui/src/components/Clients.vue
@@ -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>
-- 
GitLab