From 5946a84da5d74381a5288cda669ca764a798574b Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 13 Apr 2024 14:27:07 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix(frontend):=20=E6=8B=A1=E5=BC=B5?= =?UTF-8?q?=E5=AD=90=E5=86=85=E3=81=AB=E3=83=89=E3=83=83=E3=83=88=E3=81=8C?= =?UTF-8?q?=E5=90=AB=E3=81=BE=E3=82=8C=E3=82=8B=E3=82=82=E3=81=AE=E3=82=92?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E3=81=AB=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit f3a7b48dfd5102fbb5332828f1392b7982bc9e41) --- packages/frontend/src/scripts/upload.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/scripts/upload.ts b/packages/frontend/src/scripts/upload.ts index 3e947183c9ea..8172deca7715 100644 --- a/packages/frontend/src/scripts/upload.ts +++ b/packages/frontend/src/scripts/upload.ts @@ -29,6 +29,26 @@ const mimeTypeMap = { 'image/png': 'png', } as const; +// tar.gzなど、拡張子内にドットが含まれるものはここに追加 +const specialExtensions = [ + 'tar.gz', + 'tar.bz2', + 'tar.xz', + 'tar.zst', + 'tar.lz', + 'tar.lz4', + 'tar.sz', + 'tar.z', +] as const; + +function getExtension(filename: string): string { + for (const ext of specialExtensions) { + if (filename.endsWith('.' + ext)) return '.' + ext; + } + const parts = filename.split('.'); + return parts.length > 1 ? '.' + parts.pop()! : ''; +} + export function uploadFile( file: File, folder?: any, @@ -45,7 +65,7 @@ export function uploadFile( const reader = new FileReader(); reader.onload = async (): Promise => { const filename = name ?? file.name ?? 'untitled'; - const extension = filename.split('.').length > 1 ? '.' + filename.split('.').pop() : ''; + const extension = getExtension(filename); const ctx = reactive({ id, From 2e7a82935c821955b8f22cd458d79131d09a5e87 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 13 Apr 2024 19:04:21 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8B=A1=E5=BC=B5=E5=AD=90=E5=86=85?= =?UTF-8?q?=E3=81=AB=E3=83=89=E3=83=83=E3=83=88=E3=82=922=E3=81=A4?= =?UTF-8?q?=E3=81=BE=E3=81=A7=E8=A8=B1=E5=AE=B9=E3=81=99=E3=82=8B=E3=82=82?= =?UTF-8?q?=E3=81=AE=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B=E4=BB=95?= =?UTF-8?q?=E6=A7=98=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 754bb92a68712d1382d7d23ebbfc87a83bf7fdfb) --- packages/frontend/src/scripts/upload.ts | 30 +++++++++++++++---------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/frontend/src/scripts/upload.ts b/packages/frontend/src/scripts/upload.ts index 8172deca7715..9440e526fad5 100644 --- a/packages/frontend/src/scripts/upload.ts +++ b/packages/frontend/src/scripts/upload.ts @@ -29,24 +29,30 @@ const mimeTypeMap = { 'image/png': 'png', } as const; -// tar.gzなど、拡張子内にドットが含まれるものはここに追加 +// tar.gzなど、拡張子内にドットを2つまで許容するものはここに追加 const specialExtensions = [ - 'tar.gz', - 'tar.bz2', - 'tar.xz', - 'tar.zst', - 'tar.lz', - 'tar.lz4', - 'tar.sz', - 'tar.z', + 'gz', + 'bz2', + 'xz', + 'zst', + 'lz', + 'lz4', + 'sz', + 'z', + 'zstd', ] as const; function getExtension(filename: string): string { + const parts = filename.split('.'); + + if (parts.length <= 1) return ''; + for (const ext of specialExtensions) { - if (filename.endsWith('.' + ext)) return '.' + ext; + if (parts[parts.length - 1] === ext && parts.length > 2) { + return '.' + parts[parts.length - 2] + '.' + parts[parts.length - 1]; + } } - const parts = filename.split('.'); - return parts.length > 1 ? '.' + parts.pop()! : ''; + return '.' + parts.pop(); } export function uploadFile( From dd7b1a13ca83f4741b6af9b2de56dd86bfe5c687 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Mon, 3 Jun 2024 13:56:14 +0900 Subject: [PATCH 3/3] =?UTF-8?q?docs(changelog):=20=E3=83=A9=E3=83=B3?= =?UTF-8?q?=E3=83=80=E3=83=A0=E6=96=87=E5=AD=97=E5=88=97=E3=81=A7=E3=82=A2?= =?UTF-8?q?=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89=E3=81=99=E3=82=8B?= =?UTF-8?q?=E9=9A=9B=E3=81=AB=E6=8B=A1=E5=BC=B5=E5=AD=90=E5=86=85=E3=81=AB?= =?UTF-8?q?=E3=83=89=E3=83=83=E3=83=88=E3=81=8C=E5=90=AB=E3=81=BE=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=82=E3=81=AE=E3=82=92=E6=AD=A3=E5=B8=B8=E3=81=AB?= =?UTF-8?q?=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 559db42d4789..f04ad9e1123e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ### General - Fix: パブリック投稿をホーム投稿に変更するモデレーション操作がリプライに正しく適用されていなかった問題を修正 +### Client +- Fix: ランダム文字列でアップロードする際に拡張子内にドットが含まれるものを正常にアップロードできるように + ## 2024.5.0 (merged to 2024.5.0-kinel.1) ### Note