Add max_length settings to export zip

This commit is contained in:
2023-06-14 18:18:54 +08:00
parent f46ad802f8
commit 8140a42a47
7 changed files with 43 additions and 6 deletions

View File

@@ -141,8 +141,13 @@ export function filterFilename(p: string, maxLength = 256) {
} else if (Deno.build.os == "linux") {
p = p.replace(/[!\$\"]/g, "_");
}
if (p.length > maxLength) {
return limitFilename(p, maxLength);
}
export function limitFilename(p: string, maxLength: number) {
if (maxLength > 0 && p.length > maxLength) {
const ext = extname(p);
if (maxLength < ext.length) return ext;
return p.slice(0, maxLength - ext.length) + ext;
}
return p;