Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useEffect } from "react";
import { Button } from "@heroui/react";
import { AlertCircle, RefreshCcw } from "lucide-react";
import { AlertCircle, RefreshCcw, RotateCcw } from "lucide-react";
import { reportError } from "@/lib/error-reporting";

export default function Error({
Expand Down Expand Up @@ -34,6 +34,7 @@ export default function Error({
onClick={() => window.location.reload()}
className="focus-ring rounded-xl px-8"
>
<RotateCcw className="h-4 w-4 mr-2" aria-hidden="true" />
Reload Page
</Button>
<Button
Expand Down
8 changes: 6 additions & 2 deletions app/lib/error-reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ function sanitizeError(data: Error, seen: WeakSet<object>): Error {

function sanitizeObject(data: Record<string, unknown>, seen: WeakSet<object>): Record<string, unknown> {
const sanitizedObj: Record<string, unknown> = {};
for (const [key, value] of Object.entries(data)) {
sanitizedObj[key] = SENSITIVE_KEY_PATTERN.test(key) ? "[REDACTED]" : sanitize(value, seen);
for (const key in data) {
if (Object.hasOwn(data, key)) {
sanitizedObj[key] = SENSITIVE_KEY_PATTERN.test(key)
? "[REDACTED]"
: sanitize(data[key], seen);
}
}
return sanitizedObj;
}
Expand Down
4 changes: 1 addition & 3 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ const JSON_LD_STRING = safeJsonLdStringify(JSON_LD);
export default function Page() {
return (
<div className="flex flex-col gap-20 pb-20">
<script type="application/ld+json">
{JSON_LD_STRING}
</script>
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON_LD_STRING }} />
<Hero />
<Features />
</div>
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/app/error.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ describe("Error component", () => {
expect(mockReset).toHaveBeenCalledTimes(1);
});

it("ensures decorative icons are hidden from screen readers", () => {
const { container } = render(
<ErrorComponent error={mockError} reset={mockReset} />
);
const svgs = container.querySelectorAll("svg");
expect(svgs.length).toBeGreaterThan(0);
svgs.forEach((svg) => {
expect(svg).toHaveAttribute("aria-hidden", "true");
});
});

it("reloads the page when 'Reload Page' button is clicked", () => {
const reloadMock = vi.fn();

Expand Down
Loading