Skip to content
Open
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
27 changes: 25 additions & 2 deletions admin/src/lib/components/RequestsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -84,7 +107,7 @@ export default function RequestsTable(props: Props): JSX.Element {
</TableHead>
<TableBody>
{requests.map(({ id, method, url, response }) => {
const { origin, pathname, search, hash } = new URL(url);
const { origin, path } = parseURLForDisplay(url);

return (
<RequestTableRow
Expand All @@ -102,7 +125,7 @@ export default function RequestsTable(props: Props): JSX.Element {
<code>{method}</code>
</MethodTableCell>
<OriginTableCell>{origin}</OriginTableCell>
<PathTableCell>{decodeURIComponent(pathname + search + hash)}</PathTableCell>
<PathTableCell>{path}</PathTableCell>
<StatusTableCell>
{response && <Status code={response.statusCode} reason={response.statusReason} />}
</StatusTableCell>
Expand Down