Skip to content

Commit 8261b7a

Browse files
committed
Output port as an int, not string
1 parent ca507f0 commit 8261b7a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net/url"
99
"os"
1010
"sort"
11+
"strconv"
1112
"strings"
1213
)
1314

@@ -117,7 +118,12 @@ func toOutLine(rawURL string, headers []string, data, method string, ps []string
117118
u := parseURL(doReplacements(rawURL, ps, pvs))
118119
j["host"] = u.Hostname()
119120
if u.Port() != "" {
120-
j["port"] = u.Port()
121+
var err error
122+
j["port"], err = strconv.Atoi(u.Port())
123+
if err != nil {
124+
fmt.Fprintf(os.Stderr, "Error: Could not parse port '%s': %v\n", u.Port(), err)
125+
os.Exit(1)
126+
}
121127
}
122128
j["tls"] = u.Scheme == "https"
123129
j["req"] = toRequest(u, headers, data, method, ps, pvs)

0 commit comments

Comments
 (0)