Malformed clone_url generated when repo URL is in ssh:// format (regex isn't anchored)

Open Beginner friendly
#797 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
frontend

Research direction

Start in client/src/components/apps/form.vue, in updateApp() around lines 2307-2312, and inspect how ssh_url is transformed into clone_url. Reproduce with an ssh://user@host/path.git repository, save the app, and inspect the resulting clone_url on the KuberoApp CR. Done means the value is a valid https://host/path.git URL without the ssh:// prefix.

Written by the indexing model from the issue text.

Description

bug
Which component(s) is affected?

Kubero CLI

Describe the bug

In client/src/components/apps/form.vue (updateApp(), around line 2307-2312), clone_url is derived from ssh_url using this regex:

js
const regex = /(git@|ssh:|http[s]?://)([\w.]+)(:|/)([\w/-~]+)(.git)?/;
this.gitrepo.clone_url = this.gitrepo.ssh_url.replace(regex, "https://$2/$4$5");

This works for the scp-style git@host:path format, but not for ssh://user@host/path format. Since the regex isn't anchored to the start of the string, when matching against ssh://git@github.com/foo/bar.git, the ssh: alternative fails to match at position 0 (the next character is /, not a word character), so the engine slides forward and matches starting at git@ instead. .replace() only swaps out the matched substring, leaving the ssh:// prefix untouched.

Steps to reproduce
  1. Edit an app's git repository field in the Kubero UI with a URL in ssh://user@host/path.git format
  2. Save
  3. Inspect the resulting clone_url on the KuberoApp CR
Expected behavior

Expected behavior: clone_url should be a valid https://host/path.git URL.

Actual behavior: clone_url becomes ssh://https://host/path.git — malformed and unusable for cloning.

Suggested fix: Anchor the regex (^) or use a proper URL-parsing approach instead of a permissive unanchored match.

Screenshots

No response

Additional information

No response

Debug information

No response

Dominant language
TypeScript
Stars
4.4k
Forks
212
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kubero-dev/kubero

All issues in kubero-dev/kubero

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.