mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix(projects): harden host and remote identity
This commit is contained in:
@@ -17,4 +17,22 @@ describe("project settings target", () => {
|
||||
it("keeps a host-local route valid after the structural key changes", () => {
|
||||
expect(findProjectSettingsTarget([project], "host:host-a:project:prj_1234")).toBe(project);
|
||||
});
|
||||
|
||||
it("keeps legacy project IDs scoped to their host", () => {
|
||||
const legacyKey = "remote:github.com/acme/app";
|
||||
const unchangedProject = {
|
||||
projectKey: legacyKey,
|
||||
hosts: [{ serverId: "host-a", projectId: legacyKey }],
|
||||
};
|
||||
const changedProject = {
|
||||
projectKey: "remote:github.com/acme/app-fork",
|
||||
hosts: [{ serverId: "host-b", projectId: legacyKey }],
|
||||
};
|
||||
|
||||
const routeKey = resolveProjectSettingsRouteKey(changedProject);
|
||||
expect(routeKey).toBe(`host:host-b:project:${legacyKey}`);
|
||||
expect(findProjectSettingsTarget([unchangedProject, changedProject], routeKey)).toBe(
|
||||
changedProject,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { resolveProjectGroupKey } from "./project-group-key";
|
||||
|
||||
interface ProjectSettingsTarget {
|
||||
projectKey: string;
|
||||
hosts: ReadonlyArray<{ serverId: string; projectId?: string }>;
|
||||
@@ -8,7 +6,7 @@ interface ProjectSettingsTarget {
|
||||
function resolveHostLocalProjectKey(host: { serverId: string; projectId?: string }): string | null {
|
||||
const projectId = host.projectId?.trim();
|
||||
if (!projectId) return null;
|
||||
return resolveProjectGroupKey({ serverId: host.serverId, projectId });
|
||||
return `host:${host.serverId}:project:${projectId}`;
|
||||
}
|
||||
|
||||
export function resolveProjectSettingsRouteKey(project: ProjectSettingsTarget): string {
|
||||
|
||||
Reference in New Issue
Block a user