Support github URLs without protocol

This commit is contained in:
Christian Muehlhaeuser 2019-11-25 04:55:09 +01:00
commit 1baefbbec1
2 changed files with 15 additions and 11 deletions

View file

@ -8,13 +8,17 @@ import (
)
// isGitHubURL tests a string to determine if it is a well-structured GitHub URL
func isGitHubURL(s string) bool {
u, err := url.ParseRequestURI(s)
if err != nil {
return false
func isGitHubURL(s string) (string, bool) {
if strings.HasPrefix(s, "github.com/") {
s = "https://" + s
}
return strings.ToLower(u.Host) == "github.com"
u, err := url.ParseRequestURI(s)
if err != nil {
return "", false
}
return u.String(), strings.ToLower(u.Host) == "github.com"
}
// findGitHubREADME tries to find the correct README filename in a repository