diff --git a/github.go b/github.go index 6b94bb9e..6b169fa6 100644 --- a/github.go +++ b/github.go @@ -53,5 +53,5 @@ func findGitHubREADME(u *url.URL) (*source, error) { } } - return nil, errors.New(fmt.Sprintf("Can't find README in GitHub repository. Response status: %d %s", res.StatusCode, res.Status)) + return nil, errors.New("can't find README in GitHub repository") } diff --git a/gitlab.go b/gitlab.go index a69c59ae..05e12392 100644 --- a/gitlab.go +++ b/gitlab.go @@ -57,5 +57,5 @@ func findGitLabREADME(u *url.URL) (*source, error) { } } - return nil, errors.New(fmt.Sprintf("Can't find README in GitLab repository. Response status: %d %s", res.StatusCode, res.Status)) + return nil, errors.New("can't find README in GitLab repository") } diff --git a/glow_test.go b/glow_test.go index 08d90c7d..8743be29 100644 --- a/glow_test.go +++ b/glow_test.go @@ -1,41 +1,9 @@ package main import ( - "bytes" - "errors" - "net" "testing" ) -func TestGlowSources(t *testing.T) { - tt := []string{ - ".", - "README.md", - "github.com/charmbracelet/glow", - "github://charmbracelet/glow", - "https://github.com/charmbracelet/glow", - } - - for _, v := range tt { - t.Run(v, func(t *testing.T) { - buf := &bytes.Buffer{} - err := executeArg(rootCmd, v, buf) - if err != nil { - // Check for network issues. - var netErr *net.DNSError - if errors.As(err, &netErr) { - t.Logf("Error during execution (args: %s): %v", v, err) - t.Skip("Test uses network. Are you connected to the Internet?") - } - t.Errorf("Error during execution (args: %s): %v", v, err) - } - if buf.Len() == 0 { - t.Errorf("Output buffer should not be empty (args: %s)", v) - } - }) - } -} - func TestGlowFlags(t *testing.T) { tt := []struct { args []string diff --git a/main.go b/main.go index 2dbda6f1..fb3ce57e 100644 --- a/main.go +++ b/main.go @@ -76,9 +76,9 @@ func sourceFromArg(arg string) (*source, error) { // a GitHub or GitLab URL (even without the protocol): src, err := readmeURL(arg) - if src != nil { - // if there's a valid URL created, exit. - return src, err + if src != nil && err == nil { + // if there's an error, try next methods... + return src, nil } // HTTP(S) URLs: