ascorbic / unpic

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

feat: add support for cloudflare images without custom domain #131

Open dawaltconley opened 3 months ago

dawaltconley commented 3 months ago

Should fix #111

I wrote this pretty quick, fyi, as a patch for a project where I only need to support imagedelivery.net images.

Flagging the added filter here that removes empty transformation queries.

  const transformString = Object.entries(transformations)
    .filter(([key, value]) => Boolean(key) && value !== undefined)
    .map(([key, value]) => `${key}=${value}`)
    .join(",");

I added this because the current regex would pick up an image variant (e.g. /public) as a query and include it in the transform string (?public=undefined). But this change could potentially affect other cloudflare_image urls if I'm not understanding how their transformation queries work.