Skip to content

Commit 68e330f

Browse files
committed
fix(web): collapse redundant png fallback in deriveImageFilenameFromUrl
Cursor Bugbot caught the `|| "png"` on `const ext = subtype || "png"` being dead code: `subtype` already had the same fallback on the line above, so `ext === subtype` always. This is the same "redundant fallback that reads defensive but isn't" shape worth remembering for future reviews. Also moved the extension lookup below the "already has an extension" early return — we only need an inferred extension when we're about to append one. No behavior change. Existing tests still cover both branches.
1 parent 42d36da commit 68e330f

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎apps/web/src/composer-logic.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,8 @@ export function deriveImageFilenameFromUrl(url: string, mimeType: string): strin
389389
const cleaned = decodeURIComponent(last)
390390
.replace(/[\r\n\t]/g, "")
391391
.trim();
392-
const subtype = mimeType.split("/")[1]?.split(";")[0]?.trim() || "png";
393-
const ext = subtype || "png";
394392
if (cleaned && /\.[a-z0-9]{1,6}$/i.test(cleaned)) return cleaned;
393+
const ext = mimeType.split("/")[1]?.split(";")[0]?.trim() || "png";
395394
if (cleaned) return `${cleaned}.${ext}`;
396395
return `dropped-image.${ext}`;
397396
}

0 commit comments

Comments
 (0)