Skip to content

Commit

Permalink
Output port as an int, not string
Browse files Browse the repository at this point in the history
  • Loading branch information
codesoap committed Dec 21, 2023
1 parent ca507f0 commit 8261b7a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/url"
"os"
"sort"
"strconv"
"strings"
)

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

0 comments on commit 8261b7a

Please sign in to comment.