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:
parent
29504c884b
commit
c1613d8a21
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue