From 2cb8179b60606009d83ec69b55666792b5ca1fda Mon Sep 17 00:00:00 2001 From: bashbunni Date: Wed, 4 Dec 2024 17:06:37 -0800 Subject: [PATCH] fix: return if a valid URL is generated --- main.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index f1075251..2dbda6f1 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,6 @@ import ( "fmt" "io" "io/fs" - "net" "net/http" "net/url" "os" @@ -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 != "" {