Browse Source

fileeditable filename with accent bug fix

bach 1 month ago
parent
commit
984ec07084
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/components/editable/FileEditable.vue

+ 4 - 1
src/components/editable/FileEditable.vue

@@ -51,11 +51,14 @@ export default {
       this.saveNewFile(file);
     },
     saveNewFile(file){
+      const filename = file.name.normalize('NFD').replace(/[\u0300-\u036f]/g, "").replace(/[^a-zA-Z0-9_\-\.]/g, "_");  // Normalisation Unicode et suppression des accents
+      console.log('filename', filename);
+      
       const configs = {
         headers: {
           'X-CSRF-Token': this.csrf_token,
           'Content-Type': 'application/octet-stream',
-          'Content-Disposition': `file; filename="${file.name}"`,
+          'Content-Disposition': `file; filename="${filename}"`,
         },
       };