fix(navigation): ignore malformed server ids on remote project routes

This commit is contained in:
Chris Scott committed 2026-10-19 11:42:47 -04:00
1 parent 24745597f2
commit a926991637
2 files changed
+4 -2

No files matched your search

+1
View File
@@ -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();
});
});
+3 -2
View File
@@ -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 {