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 {