Check for supported HTTP/HTTPS protocols explicitly

This commit is contained in:
Christian Muehlhaeuser 2019-11-25 05:14:25 +01:00
parent e40b04218e
commit 2bfaa5ece9

View file

@ -8,7 +8,6 @@ import (
"net/http"
"net/url"
"os"
"strings"
"github.com/mattn/go-isatty"
"github.com/spf13/cobra"
@ -43,7 +42,7 @@ func readerFromArg(s string) (io.ReadCloser, error) {
}
if u, err := url.ParseRequestURI(s); err == nil {
if !strings.HasPrefix(u.Scheme, "http") {
if u.Scheme != "http" && u.Scheme != "https" {
return nil, fmt.Errorf("%s is not a supported protocol", u.Scheme)
}
@ -61,7 +60,7 @@ func readerFromArg(s string) (io.ReadCloser, error) {
for _, v := range readmeNames {
r, err := os.Open(v)
if err == nil {
return r, err
return r, nil
}
}