Bug fix: A gallery may contains two image which have same name

This commit is contained in:
2023-06-10 21:11:17 +08:00
parent a5488dcd35
commit eb146e826d
3 changed files with 36 additions and 2 deletions

View File

@@ -152,3 +152,15 @@ export function configureZipJs() {
configure({ useWebWorkers: false });
zipjs_configured = true;
}
export function add_suffix_to_path(path: string, suffix?: string) {
if (suffix === undefined) {
suffix = Math.round(Math.random() * 100000).toString();
}
const ext = extname(path);
if (ext) {
return `${path.slice(0, path.length - ext.length)}-${suffix}${ext}`;
} else {
return `${path}-${suffix}`;
}
}