Skip to content

Commit 70b435b

Browse files
authored
fix(x2a): Project creation template now able to start init phase (#2349)
* Deletion fixes: k8s job delete -> error on UI, delete k8s jobs before delete on DB * revert change on Pending state * fixing URL normalization error * after rebase * rebase
1 parent 9daf636 commit 70b435b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

workspaces/x2a/plugins/x2a-common/src/utils/normalizeRepoUrl.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ describe('normalizeRepoUrl', () => {
7575
expect(normalizeRepoUrl(invalid)).toBe(invalid);
7676
});
7777

78+
it('extracts repo name when repo param contains a full URL', () => {
79+
expect(
80+
normalizeRepoUrl(
81+
'github.com?owner=test-user&repo=https%3A%2F%2Fgithub.com%2Ftest-user%2Fchef-examples',
82+
),
83+
).toBe('https://github.com/test-user/chef-examples.git');
84+
});
85+
7886
it('handles URL-encoded owner and repo', () => {
7987
// URLSearchParams decodes automatically
8088
expect(normalizeRepoUrl('github.com?owner=some%20user&repo=my-repo')).toBe(

workspaces/x2a/plugins/x2a-common/src/utils/normalizeRepoUrl.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ export function normalizeRepoUrl(url: string): string {
3838
const parsed = new URL(`https://${url.trim()}`);
3939
const host = parsed.host;
4040
const owner = parsed.searchParams.get('owner') ?? '';
41-
const repo = parsed.searchParams.get('repo') ?? '';
41+
let repo = parsed.searchParams.get('repo') ?? '';
42+
43+
// If repo param contains a full URL (user pasted a URL into the repo field),
44+
// extract just the repository name from the path.
45+
if (repo.startsWith('https://') || repo.startsWith('http://')) {
46+
const repoUrl = new URL(repo);
47+
const segments = repoUrl.pathname.split('/').filter(Boolean);
48+
repo = segments[segments.length - 1] ?? repo;
49+
}
4250

4351
// GitHub / GitLab style: host?owner=someone&repo=myrepo
4452
if (owner && repo) {

0 commit comments

Comments
 (0)