Skip to content

fix: resolve 4 bugs in SVG download and copy functionality#1013

Open
piuclaw wants to merge 2 commits into
pheralb:mainfrom
piuclaw:main
Open

fix: resolve 4 bugs in SVG download and copy functionality#1013
piuclaw wants to merge 2 commits into
pheralb:mainfrom
piuclaw:main

Conversation

@piuclaw

@piuclaw piuclaw commented Jul 6, 2026

Copy link
Copy Markdown

Hi @pheralb!

Thanks for building such a great project. I found and fixed 4 bugs that affect the download and copy functionality:

getSource.ts — Added response.ok check: Previously, error pages (404, 500) were being processed as valid SVG content, causing corrupt downloads. Now it throws an error when the fetch fails.

downloadSvg.svelte — Removed redundant ternaries: Expressions like isDarkTheme() ? route : route always returned the same value regardless of theme. Simplified to just use the value directly.

/api/svgs/svgr/+server.ts — Added input validation: Sending a POST request without code or name fields caused a 500 error. Now it returns a proper 400 response with a clear error message.

copySvg.svelte — Added error handling to converters: React, Angular, Web, and Astro converters did not have try/catch blocks. If getSource() failed, isLoading was never reset, leaving the user with an infinite spinner. Now all converters properly handle errors and reset the loading state.

All fixes include proper error handling and follow the existing code patterns. Let me know if you have any questions!

- getSource.ts: Add response.ok check to prevent processing error pages as valid SVG
- downloadSvg.svelte: Remove redundant ternary expressions that always returned same value
- /api/svgs/svgr/+server.ts: Add input validation for code and name fields
- copySvg.svelte: Add try/catch to React, Angular, Web, and Astro converters to reset loading state on error
Run format on files changed in the download/copy bugfix PR.
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.

1 participant