fix(projects): preserve exact placement identity

This commit is contained in:
Mohamed Boudra
2026-07-29 02:48:30 +00:00
parent 3e66464b2e
commit f054e403a6
8 changed files with 71 additions and 39 deletions
@@ -159,6 +159,21 @@ describe("deriveProjectGroupKey", () => {
);
});
test("preserves leading whitespace in SCP repository paths", () => {
const rootPath = path.resolve("repo");
const derive = (remoteUrl: string) =>
deriveProjectGroupKey({
rootPath,
remoteUrl,
worktreeRoot: rootPath,
mainRepoRoot: null,
});
expect(derive("git@example.com: acme/repo.git")).not.toBe(
derive("git@example.com:acme/repo.git"),
);
});
test("does not parse drive-relative Windows paths as SCP remotes", () => {
const rootPath = path.resolve("repo");
@@ -50,9 +50,8 @@ function encodeSelectedPath(selectedPath: string): string {
}
function deriveRemoteProjectGroupKey(remoteUrl: string | null): string | null {
const trimmed = remoteUrl?.trim();
if (!trimmed) return null;
const remote = parseRemoteLocation(trimmed);
if (!remoteUrl?.trim()) return null;
const remote = parseRemoteLocation(remoteUrl);
if (!remote) return null;
const cleanedPath = normalizeRemotePath(
remote.path,
@@ -143,7 +142,7 @@ function normalizeRemotePath(
decodePercentEncoding: boolean,
stripDotGitSuffix: boolean,
): string {
const trimmedPath = remotePath.trim().replace(/\/+$/, "");
const trimmedPath = remotePath.replace(/\/+$/, "");
const pathForEncoding = preserveLeadingSlash ? trimmedPath : trimmedPath.replace(/^\/+/, "");
const segments = pathForEncoding.split("/");
const decodedSegments = segments.map((segment) => {