mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(navigation): ignore malformed server ids on remote project routes
This commit is contained in:
1 parent
24745597f2
commit
a926991637
2 files changed
+4
-2
No files matched your search
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user