Skip to content
Snippets Groups Projects
Commit 3bf80d99 authored by Tamer Tas's avatar Tamer Tas
Browse files

pkg/host: implement git url calculation for GitHub repositories

parent b605b84d
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,10 @@ import ( ...@@ -5,7 +5,10 @@ import (
"strings" "strings"
) )
const githubStorageURL = "https://codeload.github.com" const (
githubURL = "https://github.com"
githubStorageURL = "https://codeload.github.com"
)
// ZipURL returns the URL of the zip archive given a github repository URL. // ZipURL returns the URL of the zip archive given a github repository URL.
func ZipURL(repo string) string { func ZipURL(repo string) string {
...@@ -34,3 +37,13 @@ func ZipURL(repo string) string { ...@@ -34,3 +37,13 @@ func ZipURL(repo string) string {
return strings.Join(urlTokens, "/") return strings.Join(urlTokens, "/")
} }
// URL returns the normalized URL of a GitHub repository.
func URL(repo string) string {
githubRegex := regexp.MustCompile(githubURL + `/(\S+)$`)
if githubRegex.MatchString(repo) {
return repo
}
return strings.Join([]string{githubURL, repo}, "/")
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment