Assert unrecognized Cloudinary URL variant throws in transformCloudinaryImage#25
Conversation
Adds a throw statement after the three known path-segment branches so that a Cloudinary URL that matches none of upload/, fetch/, or youtube/ fails loudly instead of silently returning the untransformed URL. Updates the existing test case to expect the new error. Closes #22 https://claude.ai/code/session_01LWPHUTNZkL6Ww9RungK9Hg
There was a problem hiding this comment.
Pull request overview
Adds an explicit error throw in transformCloudinaryImage when a Cloudinary URL does not match any recognized path segment (upload/, fetch/, youtube/), replacing the previous silent fallthrough. The corresponding test is updated to assert the new throw behavior.
Changes:
- Throw a descriptive
Errorafter the three known path-segment branches. - Update the matching unit test to expect the thrown error instead of an unchanged URL.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| io/cloudinary/transformCloudinaryImage.ts | Adds throw new Error(...) for unrecognized Cloudinary URL variants. |
| io/cloudinary/transformCloudinaryImage.test.ts | Updates test to assert the new error is thrown. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code ReviewOverviewThis PR converts a silent no-op (returning the URL unchanged) into a fail-fast error when What works well
Minor observations (non-blocking)1. Hostname check is loose if (url.includes('cloudinary')) {This matches any URL with the word "cloudinary" anywhere in it (path, query, etc.), not just if (new URL(url).hostname === 'res.cloudinary.com') {This is a pre-existing issue, not introduced here, and unlikely to cause real-world problems given the URL patterns in use — just worth flagging. 2. Path-segment checks have the same looseness if (url.includes('upload/')) {
if (url.includes('fetch/')) {
if (url.includes('youtube/')) {A SummaryLGTM. The change is correct, minimal, and clearly improves the function's behaviour. The two pre-existing loose checks are worth addressing eventually (perhaps a follow-up issue), but they don't block this PR. |
Summary
upload/,fetch/,youtube/), adds athrow new Error(...)when a Cloudinary URL matches none of the recognized variants.Test plan
transformCloudinaryImagethrows for a Cloudinary URL with an unrecognized path segmentCloses #22
https://claude.ai/code/session_01LWPHUTNZkL6Ww9RungK9Hg
Generated by Claude Code