Normalized Routing
This commit is contained in:
@@ -123,7 +123,7 @@ func parseRepoSpec(raw string) (giteaRepoSpec, bool) {
|
||||
if len(parts) < 2 {
|
||||
return giteaRepoSpec{}, false
|
||||
}
|
||||
base := (&url.URL{Scheme: "https", Host: u.Hostname()}).String()
|
||||
base := (&url.URL{Scheme: "https", Host: normalizeGiteaHTTPHost(u.Hostname())}).String()
|
||||
if u.Scheme == "http" || u.Scheme == "https" {
|
||||
base = (&url.URL{Scheme: u.Scheme, Host: u.Host}).String()
|
||||
}
|
||||
@@ -139,12 +139,20 @@ func parseRepoSpec(raw string) (giteaRepoSpec, bool) {
|
||||
if len(parts) < 2 {
|
||||
return giteaRepoSpec{}, false
|
||||
}
|
||||
base := (&url.URL{Scheme: "https", Host: hostAndPath[0]}).String()
|
||||
base := (&url.URL{Scheme: "https", Host: normalizeGiteaHTTPHost(hostAndPath[0])}).String()
|
||||
return giteaRepoSpec{BaseURL: strings.TrimRight(base, "/"), Owner: parts[len(parts)-2], Repo: parts[len(parts)-1]}, true
|
||||
}
|
||||
return giteaRepoSpec{}, false
|
||||
}
|
||||
|
||||
func normalizeGiteaHTTPHost(host string) string {
|
||||
host = strings.TrimSpace(host)
|
||||
if strings.HasPrefix(host, "git-ssh.") {
|
||||
return "gitea." + strings.TrimPrefix(host, "git-ssh.")
|
||||
}
|
||||
return host
|
||||
}
|
||||
|
||||
func resolvePartsManifestAssetURL(spec giteaRepoSpec) (string, error) {
|
||||
apiURL := fmt.Sprintf("%s/api/v1/repos/%s/%s/releases/tags/%s", strings.TrimRight(spec.BaseURL, "/"), url.PathEscape(spec.Owner), url.PathEscape(spec.Repo), url.PathEscape(partsManifestReleaseTag))
|
||||
var release struct {
|
||||
|
||||
Reference in New Issue
Block a user