fix(electron): filename escape (#9583)

This commit is contained in:
forehalo
2025-01-08 07:31:08 +00:00
parent a4841bbfa3
commit 0554df6bc2

View File

@@ -44,8 +44,9 @@ export function escapeFilename(name: string) {
// replace all special characters with '_' and replace repeated '_' with a single '_' and remove trailing '_' // replace all special characters with '_' and replace repeated '_' with a single '_' and remove trailing '_'
return name return name
.replaceAll(/[\\/!@#$%^&*()+~`"':;,?<>|]/g, '_') .replaceAll(/[\\/!@#$%^&*()+~`"':;,?<>|]/g, '_')
.replaceAll(/_+/g, '_') .split('_')
.replace(/_+$/, ''); .filter(Boolean)
.join('_');
} }
export async function getSpaceDBPath( export async function getSpaceDBPath(