serverless-image-handler icon indicating copy to clipboard operation
serverless-image-handler copied to clipboard

v4.0 regex for identifying Thumbor request does not work

Open soupy1976 opened this issue 7 years ago • 4 comments

The regex for identifying Thumbor requests has some problems:

const matchThumbor = new RegExp(/^(\/?)((fit-in)?|(filters:.+\(.?\))?|(unsafe)?).*(.+jpg|.+png|.+webp|.+tiff|.+jpeg)$/);

    There are a couple of issues with this regex:
    - The first part is pointless, because all of the alternatives are optional, and it then does a match on anything .* - so first part has no effect as it matches anything anyway
    - The list of image file extensions is an unreliable way to match the path. For instance, I had an issue with a jpg where the file extension was capitalised.

soupy1976 avatar Jul 24 '19 10:07 soupy1976

Also this regex doesn't match tif files (single f).

kasper-sf avatar Jul 29 '19 09:07 kasper-sf

Personally I think this should match json, then fall back to thumbor style. I had to change the code because the images I was using do not have any extension

ganey avatar Jul 30 '19 08:07 ganey

Hey all, we're in the process of reviewing #130 to resolve this issue. Feel free to take a look at the changes made and provide feedback!

hayesry avatar Aug 04 '19 15:08 hayesry

We have updated our solution, and I believe your issue has been fixed. If you still see the issue with the latest version (v4.2), please feel free to reopen the issue.

You can refer to the recent changes here

beomseoklee avatar Feb 06 '20 21:02 beomseoklee