nuxt-file-storage
nuxt-file-storage copied to clipboard
storeFileLocally adds duplicate file extension when a filename is provided
Hello @NyllRE,
thank you for this awesome package.
I found a minor issue with the filenames created in the storeFileLocally method. When you actually provide a filename it takes the filename and add the file extension. So a file called data.json will be stored as data.json.json.
When one doesn't expect a certain name it's probably not a big deal. In my case it causes the need for some special handling.
I could locate the issue to following lines in storage.ts:
const filename =
typeof fileNameOrIdLength == 'number'
? `${generateRandomId(fileNameOrIdLength)}.${originalExt}`
: `${fileNameOrIdLength}.${originalExt}`
In my eyes it looks unintentional to add the originalExt in the alternative path of the statement. It would be enough to return fileNameOrIdLength.
Thank you! Alex