unpic
unpic copied to clipboard
feat: add support for cloudflare images without custom domain
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.