From 8f5ad35df7b48eb340efd817536b8de8ea9787c0 Mon Sep 17 00:00:00 2001 From: Aleksander <170264518+t-aleksander@users.noreply.github.com> Date: Mon, 3 Jun 2024 11:03:37 +0200 Subject: [PATCH 1/2] fix file extension on some browsers --- web/src/shared/utils/downloadWGConfig.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/src/shared/utils/downloadWGConfig.ts b/web/src/shared/utils/downloadWGConfig.ts index f3c357d0f2..855b8678e4 100644 --- a/web/src/shared/utils/downloadWGConfig.ts +++ b/web/src/shared/utils/downloadWGConfig.ts @@ -2,7 +2,9 @@ import saveAs from 'file-saver'; export const downloadWGConfig = (config: string, fileName: string) => { const blob = new Blob([config.replace(/^[^\S\r\n]+|[^\S\r\n]+$/gm, '')], { - type: 'text/plain;charset=utf-8', + // octet-stream is used here as a workaround: some browsers will append + // an additional .txt extension to the file name if the MIME type is text/plain. + type: 'application/octet-stream;charset=utf-8', }); saveAs(blob, `${fileName.toLowerCase()}.conf`); }; From 894e863ecd37e4fda4b95078065263d12ba68f10 Mon Sep 17 00:00:00 2001 From: Aleksander <170264518+t-aleksander@users.noreply.github.com> Date: Mon, 3 Jun 2024 11:47:28 +0200 Subject: [PATCH 2/2] remove charset as its unsued according to the standard --- web/src/shared/utils/downloadWGConfig.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/shared/utils/downloadWGConfig.ts b/web/src/shared/utils/downloadWGConfig.ts index 855b8678e4..b395a0768e 100644 --- a/web/src/shared/utils/downloadWGConfig.ts +++ b/web/src/shared/utils/downloadWGConfig.ts @@ -2,9 +2,9 @@ import saveAs from 'file-saver'; export const downloadWGConfig = (config: string, fileName: string) => { const blob = new Blob([config.replace(/^[^\S\r\n]+|[^\S\r\n]+$/gm, '')], { - // octet-stream is used here as a workaround: some browsers will append + // octet-stream is used here as a workaround: some browsers will append // an additional .txt extension to the file name if the MIME type is text/plain. - type: 'application/octet-stream;charset=utf-8', + type: 'application/octet-stream', }); saveAs(blob, `${fileName.toLowerCase()}.conf`); };