about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--htping.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/htping.go b/htping.go
index 83c6a5e..60b8480 100644
--- a/htping.go
+++ b/htping.go
@@ -368,21 +368,22 @@ func main() {
 	var wg sync.WaitGroup
 	wg.Add(len(args))
 
-	for _, mu := range args {
-		u := mu
-
-		u2, err := url.ParseRequestURI(u)
-		if (err != nil && strings.HasSuffix(err.Error(),
-			"invalid URI for request")) ||
-			(u2.Scheme != "http" && u2.Scheme != "https") {
-			u = "http://" + u
-		}
+		u := u
+
+		parsedUrl, err := url.ParseRequestURI(u)
+		if (err != nil && err.(*url.Error).Op == "parse") {
+                        u = "http://" + u
+                }
 
-		_, err = url.ParseRequestURI(u)
+		parsedUrl, err = url.ParseRequestURI(u)
 		if err != nil {
 			fmt.Fprintf(os.Stderr, "%s\n", err.Error())
 			os.Exit(1)
 		}
+		if !(parsedUrl.Scheme == "http" || parsedUrl.Scheme == "https") {
+			fmt.Fprintf(os.Stderr, "unsupported URL scheme: %s\n", u)
+			os.Exit(1)
+		}
 
 		fmt.Printf("%s %s\n", method, u)