Fix entry comment processing.

This commit is contained in:
Captain ALM 2023-12-05 22:32:13 +00:00
parent ac71484962
commit b701669648
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1

View File

@ -5,7 +5,7 @@ import "strings"
func NewHostsEntry(lineIn string) Entry {
trLineIn := strings.ReplaceAll(strings.Trim(lineIn, "\r\n"), " ", " ")
lineSplt := strings.Split(trLineIn, " ")
if len(lineSplt) == 1 && strings.HasPrefix(strings.TrimPrefix(" ", trLineIn), "#") {
if strings.HasPrefix(strings.TrimPrefix(" ", trLineIn), "#") {
return Entry{
IPAddress: "",
Domains: nil,
@ -17,7 +17,7 @@ func NewHostsEntry(lineIn string) Entry {
if lineSplt[i] == "" {
continue
}
if strings.HasPrefix(lineSplt[i], "#") {
if strings.HasPrefix(strings.TrimPrefix(" ", lineSplt[i]), "#") {
break
}
theDomains = append(theDomains, lineSplt[i])