Skip to content

Commit 8422dcd

Browse files
committed
fix(client): preserve clone URLs on unrecognized hosts
1 parent 2dc529b commit 8422dcd

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎packages/client-runtime/src/operations/projects.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ describe("add project shared logic", () => {
6969
expect(normalizePastedCloneUrl("https://gitlab.com/team/platform/src/branch/repo.git")).toBe(
7070
"https://gitlab.com/team/platform/src/branch/repo.git",
7171
);
72+
expect(
73+
normalizePastedCloneUrl("https://gitlab.example.com/team/platform/src/branch/repo.git"),
74+
).toBe("https://gitlab.example.com/team/platform/src/branch/repo.git");
75+
expect(
76+
normalizePastedCloneUrl("https://git.example.com/team/platform/src/branch/repo.git"),
77+
).toBe("https://git.example.com/team/platform/src/branch/repo.git");
7278
});
7379

7480
it.each([

‎packages/source-control-core/src/shared/definition.ts‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -740,14 +740,11 @@ export function makeSourceControlDefinitionRegistry(
740740
repositoryUrlFromPageUrl: (value) => {
741741
const url = httpUrl(value);
742742
if (url === null) return null;
743-
// Another host's any-hostname pattern can misread a public host's path, such as a GitLab
744-
// group named `src`, so a public host's URLs are read only by that host.
745-
const owner = findByPublicDomain(url.hostname);
746-
for (const definition of owner ? [owner] : claimOrder) {
747-
const repositoryUrl = definition.repositoryUrlFromPageUrl?.(url);
748-
if (repositoryUrl != null) return repositoryUrl;
749-
}
750-
return null;
743+
// Page routes can also be valid repository paths on another provider.
744+
const owner =
745+
findByPublicDomain(url.hostname) ??
746+
recognitionOrder.find((definition) => recognizeRemoteWith(definition, value) !== null);
747+
return owner?.repositoryUrlFromPageUrl?.(url) ?? null;
751748
},
752749
findByChangeRequestUrl: (url) => parseChangeRequestUrl(url)?.definition,
753750
hostLabelForChangeRequestUrl: (url) =>

0 commit comments

Comments
 (0)