Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: open the terminal, group and flow pages for a malformed address

A name or id that isn't valid percent-encoding (for example /agents/%E0%A4%A/terminal)
made decodeURIComponent throw while the page rendered, leaving a blank page. The
segment now stays as typed, as the agents page already did, so the page opens
(a terminal for that name, disconnected). A tested helper does the decoding.
This commit is contained in:
iris 2026-11-25 19:58:30 +01:00 • committed by mara
commit 79f2d4bd4d

View file

@ -28,6 +28,19 @@ export function isFullBleedRoute(location: string): boolean {
// which starts a terminal group's path (`/agents/group/:id`).
const SELECTED_AGENT_PATTERN = /^\/agents\/([^/]+)$/;
/**
* A path segment as text. A segment that isn't valid percent-encoding (a typed
* or mangled address) comes back as it is, so a page can say "no such agent"
* rather than throwing while it renders.
*/
export function safeDecode(segment: string): string {
try {
return decodeURIComponent(segment);
} catch {
return segment;
}
}
/** The agent a path selects on the agents page, or `null` for any other path. */
export function selectedAgent(location: string): string | null {
const match = SELECTED_AGENT_PATTERN.exec(location);