diff --git a/submodule.go b/submodule.go index a0fe7b4a5..cf468b490 100644 --- a/submodule.go +++ b/submodule.go @@ -4,7 +4,10 @@ package git -import "strings" +import ( + "strings" + "strconv" +) // SubModule submodule is a reference on git repository type SubModule struct { @@ -58,6 +61,8 @@ func (sf *SubModuleFile) RefURL(urlPrefix string, parentPath string) string { } // sysuser@xxx:user/repo + // or + // sysuser@xxx:port/user/repo i := strings.Index(url, "@") j := strings.LastIndex(url, ":") @@ -65,7 +70,13 @@ func (sf *SubModuleFile) RefURL(urlPrefix string, parentPath string) string { if i > -1 && j > -1 && i < j { // fix problem with reverse proxy works only with local server if strings.Contains(urlPrefix, url[i+1:j]) { - return urlPrefix + url[j+1:] + port := strings.Index(url[j+1:], "/") + _, err := strconv.ParseInt(url[j+1:j+1 + port],10,16) + if err != nil { + return urlPrefix + url[j+1:] + } else { + return urlPrefix + url[j+1 + port+1:] + } } return "http://" + url[i+1:j] + "/" + url[j+1:] }