ascorbic / unpic

Universal image CDN translator
https://unpic.pics/lib
280 stars 31 forks source link

Bug: regex won't match valid cloudflare image url's #127

Open tadeumaia opened 4 months ago

tadeumaia commented 4 months ago

Hello,

Very nice library. I'm trying to setup unpic img on my project but I'm hitting 1 problems with my url, and would like to check if it's by design or am I doing something wrong?

This is what my project uses on cloudflare images: https://www.domain.com/cdn-cgi/imagedelivery/96E5KstIXRryMlVJjlvC4g/imagens/10382508/07aa3288-fb73-4bf7-af55-3f6cb10a6416/public

This is the regex being used to cloudflare matching that I could find on the code /https?:\/\/(?<host>[^\/]+)\/cdn-cgi\/imagedelivery\/(?<accountHash>[^\/]+)\/(?<imageId>[^\/]+)\/*(?<transformations>[^\/]+)*$/g

host = https://www.domain.com/ static cloudflare path = /cdn-cgi/imagedelivery/ account hash = 96E5KstIXRryMlVJjlvC4g image patch = /imagens/10382508/07aa3288-fb73-4bf7-af55-3f6cb10a6416 transformations = /public

On cloudflare side, this url works perfectly. but it looks like this regex only allows single path image, If I try to pass only a single path image to unpic it works. (ex https://www.domain.com/cdn-cgi/imagedelivery/96E5KstIXRryMlVJjlvC4g/07aa3288-fb73-4bf7-af55-3f6cb10a6416/public works)

Is this something that could be fixed on unpic side?

Thanks for your time.