feat(archive): add double-extension-aware filename parsing helper

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-01 12:47:27 +02:00
co-authored by Claude Sonnet 5
parent a7a91a7a2e
commit 031df9a999
2 changed files with 48 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
import path from 'node:path';
const DOUBLE_EXTENSIONS = ['tar.gz', 'tar.bz2', 'tar.7z'];
export function extractExtension(filename) {
const lower = filename.toLowerCase();
const match = DOUBLE_EXTENSIONS.find((ext) => lower.endsWith(`.${ext}`));
return match ?? path.extname(filename).slice(1).toLowerCase();
}
export function stripExtension(filename) {
const ext = extractExtension(filename);
return filename.slice(0, filename.length - ext.length - 1);
}