diff --git a/admin/src/lib/components/RequestsTable.tsx b/admin/src/lib/components/RequestsTable.tsx index b3862ded..15bb97c3 100644 --- a/admin/src/lib/components/RequestsTable.tsx +++ b/admin/src/lib/components/RequestsTable.tsx @@ -67,6 +67,29 @@ interface Props { onContextMenu?: (e: React.MouseEvent, id: string) => void; } +function decodeURLPart(value: string): string { + try { + return decodeURIComponent(value); + } catch { + return value; + } +} + +function parseURLForDisplay(url: string): { origin: string; path: string } { + try { + const { origin, pathname, search, hash } = new URL(url); + return { + origin, + path: decodeURLPart(pathname + search + hash), + }; + } catch { + return { + origin: "", + path: url, + }; + } +} + export default function RequestsTable(props: Props): JSX.Element { const { requests, activeRowId, actionsCell, onRowClick, onContextMenu } = props; @@ -84,7 +107,7 @@ export default function RequestsTable(props: Props): JSX.Element { {requests.map(({ id, method, url, response }) => { - const { origin, pathname, search, hash } = new URL(url); + const { origin, path } = parseURLForDisplay(url); return ( {method} {origin} - {decodeURIComponent(pathname + search + hash)} + {path} {response && }