I’m trying to create new Files in javascript, taking the old file name and replace special characters, for example:
const changeSpecialCharacters = (word) => {
return word.replace(/[éE]/g, 'e');
};
this function works with any writable string, but when i try to clone the file.name and try to apply this function, it doesn’t work:
let oldFileName = file.name;
const newFile = new File([file], changeSpecialCharacters(oldFileName), {type: file.type}
I don’t know what is happening, i know that for example file.name is a read-only attribute and string type, but i’m making a copy of it in oldFileName. What i’m missing? Do i need to modify some properties of this “oldFileName” before apply this function?
i tried making clones of strings, modify properties