mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-09 09:49:09 +02:00
fix: check other possible readme paths/branches (#450)
* fix: check other possible readme paths/branches Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: url Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: Readme.md --------- Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
f3d0cb89da
commit
8e51396575
4 changed files with 50 additions and 42 deletions
25
github.go
25
github.go
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
|
@ -29,19 +30,21 @@ func findGitHubREADME(s string) (*source, error) {
|
|||
}
|
||||
u.Host = "raw.githubusercontent.com"
|
||||
|
||||
for _, r := range readmeNames {
|
||||
v := u
|
||||
v.Path += "/master/" + r
|
||||
for _, b := range readmeBranches {
|
||||
for _, r := range readmeNames {
|
||||
v := *u
|
||||
v.Path += fmt.Sprintf("/%s/%s", b, r)
|
||||
|
||||
// nolint:bodyclose
|
||||
// it is closed on the caller
|
||||
resp, err := http.Get(v.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// nolint:bodyclose
|
||||
// it is closed on the caller
|
||||
resp, err := http.Get(v.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
return &source{resp.Body, v.String()}, nil
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
return &source{resp.Body, v.String()}, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue