Skip to content

Commit

Permalink
fix: return if a valid URL is generated
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbunni committed Dec 5, 2024
1 parent b779218 commit 2cb8179
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io"
"io/fs"
"net"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -77,17 +76,11 @@ func sourceFromArg(arg string) (*source, error) {

// a GitHub or GitLab URL (even without the protocol):
src, err := readmeURL(arg)
// Return error if it's a network issue.
var dnsErr *net.DNSError
if errors.As(err, &dnsErr) {
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:
if u, err := url.ParseRequestURI(arg); err == nil && strings.Contains(arg, "://") {
if u.Scheme != "" {
Expand Down

0 comments on commit 2cb8179

Please sign in to comment.