fix: guard HTTP failure responses and rename res to response

- Rename `res` to `response` to follow no-abbreviation naming guideline
- Add `response.ok` check to throw on non-2xx status codes, preventing
  error page content from being silently copied to the clipboard

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
96528025 2026-03-18 14:45:08 -07:00
parent 29504c884b
commit c1613d8a21
1 changed files with 5 additions and 2 deletions

View File

@ -68,8 +68,11 @@ export function Header() {
<ContextMenuItem
onClick={async () => {
try {
const res = await fetch(DEFAULT_LOGO_URL);
const svg = await res.text();
const response = await fetch(DEFAULT_LOGO_URL);
if (!response.ok) {
throw new Error(`Failed to fetch SVG: ${response.status}`);
}
const svg = await response.text();
await navigator.clipboard.writeText(svg);
toast.success("SVG copied to clipboard");
} catch {