Skip to content

Commit

Permalink
Split port from hostname in full urls.
Browse files Browse the repository at this point in the history
  • Loading branch information
fancycode committed Feb 27, 2024
1 parent 8385211 commit 1f8b536
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions dns_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ func (m *DnsMonitor) Add(target string, callback DnsMonitorCallback) (*DnsMonito
}
hostname = parsed.Host
} else {
// Hostname with optional port passed.
// Hostname only passed.
hostname = target
if h, _, err := net.SplitHostPort(target); err == nil {
hostname = h
}
}
if h, _, err := net.SplitHostPort(hostname); err == nil {
hostname = h
}

m.mu.Lock()
Expand Down
2 changes: 1 addition & 1 deletion dns_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func TestDnsMonitor(t *testing.T) {
rec1 := newDnsMonitorReceiverForTest(t)
rec1.Expect(ips1, ips1, nil, nil)

entry1, err := monitor.Add("https://foo", rec1.OnLookup)
entry1, err := monitor.Add("https://foo:12345", rec1.OnLookup)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 1f8b536

Please sign in to comment.