fix: resolve 4 bugs in SVG download and copy functionality#1013
Open
piuclaw wants to merge 2 commits into
Open
fix: resolve 4 bugs in SVG download and copy functionality#1013piuclaw wants to merge 2 commits into
piuclaw wants to merge 2 commits into
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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!