sanitize file names
This commit is contained in:
parent
c1726f5a39
commit
50b1bc2b24
1 changed files with 5 additions and 1 deletions
|
@ -25,7 +25,11 @@ export default component$(() => {
|
|||
}
|
||||
|
||||
try {
|
||||
await api.upload(uploadingFile.value as File)
|
||||
const unsafe = uploadingFile.value as File;
|
||||
const name = unsafe.name.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
||||
const f = new File([unsafe], name, { type: unsafe.type });
|
||||
|
||||
await api.upload(f);
|
||||
files.value = await api.list();
|
||||
} catch (error) {
|
||||
console.error("Error uploading file:", error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue