Skip to content

Commit

Permalink
trim spaces for host address
Browse files Browse the repository at this point in the history
  • Loading branch information
cjimti committed Jul 23, 2023
1 parent c4fba31 commit bec8513
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion txeh.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,12 @@ func (h *Hosts) HostAddressLookup(host string, ipFamily IPFamily) (bool, string,
h.Lock()
defer h.Unlock()

host = strings.ToLower(strings.TrimSpace(host))

for i, hfl := range h.hostFileLines {
for _, hn := range hfl.Hostnames {
ipAddr := net.ParseIP(hfl.Address)
if ipAddr == nil || hn != strings.ToLower(host) {
if ipAddr == nil || hn != host {
continue
}
if ipFamily == IPFamilyV4 && ipAddr.To4() != nil {
Expand Down

0 comments on commit bec8513

Please sign in to comment.