Skip to content

Commit cdaae34

Browse files
committed
fix regex for matching charset of valid DNS hosts, add test
1 parent abc4058 commit cdaae34

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

network/wsNetwork.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,8 +1913,8 @@ var errBcastQFull = errors.New("broadcast queue full")
19131913

19141914
var errURLNoHost = errors.New("could not parse a host from url")
19151915

1916-
// HostColonPortPattern matches "^[a-zA-Z0-9.]+:\\d+$" e.g. "foo.com.:1234"
1917-
var HostColonPortPattern = regexp.MustCompile("^[a-zA-Z0-9.]+:\\d+$")
1916+
// HostColonPortPattern matches "^[-a-zA-Z0-9.]+:\\d+$" e.g. "foo.com.:1234"
1917+
var HostColonPortPattern = regexp.MustCompile("^[-a-zA-Z0-9.]+:\\d+$")
19181918

19191919
// ParseHostOrURL handles "host:port" or a full URL.
19201920
// Standard library net/url.Parse chokes on "host:port".

network/wsNetwork_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,7 @@ func TestParseHostOrURL(t *testing.T) {
19901990
{"http://[::]:123", url.URL{Scheme: "http", Host: "[::]:123"}},
19911991
{"1.2.3.4:123", url.URL{Scheme: "http", Host: "1.2.3.4:123"}},
19921992
{"[::]:123", url.URL{Scheme: "http", Host: "[::]:123"}},
1993+
{"r2-devnet.devnet.algodev.network:4560", url.URL{Scheme: "http", Host: "r2-devnet.devnet.algodev.network:4560"}},
19931994
}
19941995
badUrls := []string{
19951996
"justahost",

0 commit comments

Comments
 (0)