next-image-export-optimizer
next-image-export-optimizer copied to clipboard
fix: add support for external images with query params
The library didn't work with external images that had URLs with query parameters since it encoded them into the extension, thus making it impossible to know the extension in React.
Problem demonstration
console.log(urlToFilename('https://example.com/image.png?asd=123')) // -> 'example.com_image.png_asd=123'
'png_asd=123' is not a valid extension, so the React component falls back to the original URL, basically making it meaningless to use the library.
My change
My change adds the '.png' back into the filename at the end when there is a nonempty search query.
@Niels-IO I think this might be a useful fix for a lot of people, especially those that use google storage images with presigned keys
Hi @mmtftr,
Thanks for the PR!. I will take a look but it might take me until May as I am quite busy now.
Hi @mmtftr,
Thank you very much for your PR. I changed the remote Image functionality quite a bit and your code did help me a lot. I integrated it in #220.
Hopefully, you don't mind that I didn't merge your PR directly.