From 203b4511275daecf7473399e5a8882b5bae49278 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Fri, 25 Oct 2024 17:54:36 +0200 Subject: [PATCH] fix(clustertool): allow 2 git seperators --- clustertool/pkg/initfiles/initfiles.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/clustertool/pkg/initfiles/initfiles.go b/clustertool/pkg/initfiles/initfiles.go index f7bc9a68310..3cfe06485d5 100644 --- a/clustertool/pkg/initfiles/initfiles.go +++ b/clustertool/pkg/initfiles/initfiles.go @@ -127,12 +127,14 @@ func FormatGitURL(input string) string { } // Compile a regex to match and replace the URL pattern - re := regexp.MustCompile(`^ssh://git@([^:/]+):(\w+)/(\w+)\.git$`) + re := regexp.MustCompile(`^ssh://git@([^:/]+)([:/])(\w+)/(\w+)\.git$`) matches := re.FindStringSubmatch(input) - if len(matches) == 4 { - // Reformat the URL to a generic SSH format - return fmt.Sprintf("ssh://git@%s/%s/%s.git", matches[1], matches[2], matches[3]) + if len(matches) == 5 { + // Determine the user and repo based on the separator used + user := matches[3] // Always captured as part of the matched group + repo := matches[4] // Always captured as part of the matched group + return fmt.Sprintf("ssh://git@%s/%s/%s.git", matches[1], user, repo) } return input // Return the input as is if it doesn't match