Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate new URL string for each entry in readmeNames #151

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions github.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ func findGitHubREADME(s string) (*source, error) {
return nil, err
}
u.Host = "raw.githubusercontent.com"

u.Path += "/master/"
for _, r := range readmeNames {
v := u
v.Path += "/master/" + r
v := u.String() + r

resp, err := http.Get(v.String())
resp, err := http.Get(v)
if err != nil {
return nil, err
}

if resp.StatusCode == http.StatusOK {
return &source{resp.Body, v.String()}, nil
return &source{resp.Body, v}, nil
}
}

Expand Down
9 changes: 4 additions & 5 deletions gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ func findGitLabREADME(s string) (*source, error) {
if err != nil {
return nil, err
}

u.Path += "/raw/master/"
for _, r := range readmeNames {
v := u
v.Path += "/raw/master/" + r
v := u.String() + r

resp, err := http.Get(v.String())
resp, err := http.Get(v)
if err != nil {
return nil, err
}

if resp.StatusCode == http.StatusOK {
return &source{resp.Body, v.String()}, nil
return &source{resp.Body, v}, nil
}
}

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
Version = ""
CommitSHA = ""

readmeNames = []string{"README.md", "README"}
readmeNames = []string{"readme.md", "README.md", "README", "readme"}
pager bool
style string
width uint
Expand Down