nuxt-file-storage icon indicating copy to clipboard operation
nuxt-file-storage copied to clipboard

storeFileLocally adds duplicate file extension when a filename is provided

Open kissle opened this issue 11 months ago • 0 comments

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

kissle avatar Feb 02 '25 16:02 kissle