From a926991637c324fb7aca8f7a05f0f2fea9d56899 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Mon, 19 Oct 2026 11:42:47 -0400 Subject: [PATCH] fix(navigation): ignore malformed server ids on remote project routes --- frontend/src/lib/navigation.test.ts | 1 + frontend/src/lib/navigation.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/navigation.test.ts b/frontend/src/lib/navigation.test.ts index b14df9d0..37e8c287 100644 --- a/frontend/src/lib/navigation.test.ts +++ b/frontend/src/lib/navigation.test.ts @@ -266,6 +266,7 @@ describe('getSwipeBackTarget', () => { expect(getSwipeBackTarget('/servers/%E0%A4%A/sessions/ses_1', '')).toBeNull(); expect(() => getSwipeBackTarget('/servers/srv_kitchen/sessions/%E0%A4%A', '')).not.toThrow(); expect(getSwipeBackTarget('/servers/srv_kitchen/sessions/%E0%A4%A', '')).toBeNull(); + expect(() => getSwipeBackTarget('/servers/%E0%A4%A/projects', '?directory=%2Fa')).not.toThrow(); }); }); diff --git a/frontend/src/lib/navigation.ts b/frontend/src/lib/navigation.ts index 8869885a..f6626619 100644 --- a/frontend/src/lib/navigation.ts +++ b/frontend/src/lib/navigation.ts @@ -47,8 +47,9 @@ export function parseServerProjectRoute( const match = /^\/servers\/([^/]+)\/projects$/.exec(pathname); if (!match) return null; const directory = new URLSearchParams(search).get('directory'); - if (!directory) return null; - return { serverId: decodeURIComponent(match[1]), directory }; + const serverId = decodePathSegment(match[1]); + if (!directory || !serverId) return null; + return { serverId, directory }; } function decodePathSegment(segment: string): string | null {