feat(cloudflare): add support for cloudflare's image cdn#2
Conversation
|
I'm excited to delete the custom, 100+ line image component in my app and replace it with this -- I just need it to support Cloudflare :) If it's not too much trouble, could you please push a new version to NPM of this and |
ascorbic
left a comment
There was a problem hiding this comment.
Thanks for this! Are there any default domains that it can auto-detect, or is it always the user's domain? Could you share a real example image to test it, preferably one from the Cloudflare docs.
Could you also add it to the README, but with a note saying that it's not auto-detected and needs to be manually specified. Thanks again!
|
I'll get your feedback implemented. Regarding auto detection by domain, that is not possible with cloudflare because it always uses the users domain. That said, it would be possible to detect by a pathname prefix ( |
|
@ascorbic I addressed your feedback. I wasn't able to find an image in the docs that works but I did change the URL to match what is in the docs. Also, I was able to add Cloudflare to the detection function by looking for a specific path prefix. Let me know if you think that is acceptable. |
| import { CloudflareParams, parse, transform } from "./cloudflare.ts"; | ||
|
|
||
| const img = | ||
| "https://assets.example.comeight=64,f=auto,background=red/uploads/avatar1.jpg" |
There was a problem hiding this comment.
I think something's wrong with this URL!
ascorbic
left a comment
There was a problem hiding this comment.
Good idea with the path matching. I think there are some others that we could use that approach for. Just a couple of typos left. I would really like if we can find at least one valid URL that can be used to demo this, so it can be added to the playground in examples.json. Otherwise I've no way of being sure it actually works. Comparing it to the docs only goes so far.
|
The tests are failing because of that broken url |
|
Fixed the test with a generic image from my app. Hopefully that is good enough? |
fe9f8cc to
11e36b9
Compare
Co-authored-by: Matt Kane <[email protected]>
ascorbic
left a comment
There was a problem hiding this comment.
Perfect! Thanks for your help
Fixes: #1