@n-isi-platform/design-system 1.0.27 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2606,10 +2606,30 @@ class FileUploadComponent {
|
|
|
2606
2606
|
this.translateService = translateService;
|
|
2607
2607
|
}
|
|
2608
2608
|
onSelectedFiles(event) {
|
|
2609
|
-
|
|
2609
|
+
const currentFiles = event?.currentFiles ?? [];
|
|
2610
|
+
const sanitizedFiles = currentFiles.map((file) => this.sanitizeFile(file));
|
|
2611
|
+
this.fileList = sanitizedFiles;
|
|
2610
2612
|
this.onSaveFile.emit(this.fileList);
|
|
2611
2613
|
this.calculateFileSize();
|
|
2612
2614
|
}
|
|
2615
|
+
sanitizeFile(file) {
|
|
2616
|
+
const lastDotIndex = file.name.lastIndexOf('.');
|
|
2617
|
+
const baseName = lastDotIndex > -1 ? file.name.slice(0, lastDotIndex) : file.name;
|
|
2618
|
+
const extension = lastDotIndex > -1 ? file.name.slice(lastDotIndex + 1) : '';
|
|
2619
|
+
let sanitizedBase = baseName.replace(/[^0-9A-Za-zCcŠšŽžÐdČčĆćÀ-ÿyx\s]/g, '');
|
|
2620
|
+
sanitizedBase = sanitizedBase.replace(/\s+/g, "");
|
|
2621
|
+
const sanitizedExtension = extension.replace(/[^A-Za-z0-9]/g, '');
|
|
2622
|
+
const sanitizedName = sanitizedExtension
|
|
2623
|
+
? `${sanitizedBase || 'file'}.${sanitizedExtension}`
|
|
2624
|
+
: sanitizedBase || 'file';
|
|
2625
|
+
if (sanitizedName === file.name) {
|
|
2626
|
+
return file;
|
|
2627
|
+
}
|
|
2628
|
+
return new File([file], sanitizedName, {
|
|
2629
|
+
type: file.type,
|
|
2630
|
+
lastModified: file.lastModified,
|
|
2631
|
+
});
|
|
2632
|
+
}
|
|
2613
2633
|
// Unified display name
|
|
2614
2634
|
getDisplayName(item) {
|
|
2615
2635
|
if (item instanceof File)
|