Skip to content

fix(icon-generator): handle oversized URLs in onCopyShareUrl#451

Draft
spokodev wants to merge 1 commit into
raycast:mainfrom
spokodev:fix/icon-copy-url-oversize-fallback
Draft

fix(icon-generator): handle oversized URLs in onCopyShareUrl#451
spokodev wants to merge 1 commit into
raycast:mainfrom
spokodev:fix/icon-copy-url-oversize-fallback

Conversation

@spokodev
Copy link
Copy Markdown

@spokodev spokodev commented Jun 4, 2026

Closes #444.

When a user uploads a custom image into the icon editor and clicks "Copy URL", the loading toast appears and never resolves: the URL embeds the image as base64 in search params, the shorten-url endpoint rejects requests above ~2KB, the fetch().then(res.json()) chain throws on the network/CORS failure, and the clipboard.writeText line is never reached.

The fix in app/(navigation)/icon/icon-generator.tsx:onCopyShareUrl:

  1. Pre-check the URL length. If above 2000 chars, skip the shorten request, copy the unshortened URL, and surface a toast that explains why ("URL copied (too long to shorten — custom images stay inline)").
  2. Wrap the shorten fetch in try/catch + check response.ok. Any network, CORS, or non-OK response falls through to copying the unshortened URL, so the clipboard is always written and the loading toast always resolves.

The 2KB threshold matches the issue reporter's "Staying under 2,000 characters is safest for compatibility" note and is comfortably below the practical URL length ceiling on every major browser.

Manual verification

  • Default icon → URL is short → shortens normally, toast says "URL copied to clipboard". (unchanged)
  • Upload a custom image → URL is large → toast says "URL copied (too long to shorten — custom images stay inline)", clipboard holds the full unshortened ray.so/icon?... URL that opens the editor in the same state.
  • Take the shorten endpoint offline (block via DevTools) → toast resolves with "URL copied to clipboard", clipboard holds the unshortened URL. No silent stall.

Copying a share URL from the icon editor failed silently when a custom
image was selected: the resulting URL embeds the image as base64 in
search params, which blows past the shorten-url endpoint's ~2KB ceiling.
The fetch threw, the loading toast stayed on screen, and the clipboard
was never written.

Skip the shorten step when the URL exceeds 2KB and copy the unshortened
URL with a clarifying toast. Wrap the shorten request in try/catch so
network or CORS failures fall through to the same unshortened-copy path
instead of stalling.

Closes raycast#444
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 4, 2026

@spokodev is attempting to deploy a commit to the Raycast Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Copy URL" fails silently when using a custom image instead of an icon

1 participant