mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-21 23:54:17 +02:00
Support github URLs without protocol
This commit is contained in:
parent
f09d2907bd
commit
1baefbbec1
2 changed files with 15 additions and 11 deletions
14
github.go
14
github.go
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue