From 3bf80d99f17ef8e847d1c3de3099ae693946cbd0 Mon Sep 17 00:00:00 2001
From: Tamer Tas <contact@tmrts.com>
Date: Mon, 27 Feb 2017 12:15:03 +0300
Subject: [PATCH] pkg/host: implement git url calculation for GitHub
 repositories

---
 pkg/host/github.go | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/pkg/host/github.go b/pkg/host/github.go
index 9265a3c..ff1fdd4 100644
--- a/pkg/host/github.go
+++ b/pkg/host/github.go
@@ -5,7 +5,10 @@ import (
 	"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.
 func ZipURL(repo string) string {
@@ -34,3 +37,13 @@ func ZipURL(repo string) string {
 
 	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}, "/")
+}
-- 
GitLab