Fix tab support.

This commit is contained in:
Captain ALM 2023-12-05 21:55:25 +00:00
parent 002ec28d30
commit 2d7f061aa1
Signed by untrusted user: alfred
GPG Key ID: 4E4ADD02609997B1
2 changed files with 10 additions and 1 deletions

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -3,7 +3,7 @@ package hosts
import "strings" import "strings"
func NewHostsEntry(lineIn string) Entry { func NewHostsEntry(lineIn string) Entry {
trLineIn := strings.Trim(lineIn, "\r\n") trLineIn := strings.ReplaceAll(strings.Trim(lineIn, "\r\n"), " ", " ")
lineSplt := strings.Split(trLineIn, " ") lineSplt := strings.Split(trLineIn, " ")
if len(lineSplt) == 1 && strings.HasPrefix(trLineIn, "#") { if len(lineSplt) == 1 && strings.HasPrefix(trLineIn, "#") {
return Entry{ return Entry{
@ -14,6 +14,9 @@ func NewHostsEntry(lineIn string) Entry {
} else if len(lineSplt) > 1 { } else if len(lineSplt) > 1 {
var theDomains []string var theDomains []string
for i := 1; i < len(lineSplt); i++ { for i := 1; i < len(lineSplt); i++ {
if lineSplt[i] == "" {
continue
}
if strings.HasPrefix(lineSplt[i], "#") { if strings.HasPrefix(lineSplt[i], "#") {
break break
} }