comments in config files with #

This commit is contained in:
uan
2025-08-08 13:45:20 +02:00
parent 3746cff406
commit 11dd7a3587

View File

@@ -88,8 +88,19 @@ func (ws *WebServer) parseFilterPanics(fileName string) (FilterMode, []string) {
panic("Error reading " + fileName + ": " + err.Error()) panic("Error reading " + fileName + ": " + err.Error())
} }
filterLines := strings.Split(string(filterContent), "\n") lines := strings.Split(string(filterContent), "\n")
readFilterMode := filterLines[0] var linesNoComments []string = make([]string, 0)
for _, line := range lines {
line = strings.TrimSpace(strings.Split(line, "#")[0]) // only take portion before comments
if line == "" {
continue
}
linesNoComments = append(linesNoComments, line)
}
readFilterMode := linesNoComments[0]
filter = linesNoComments[1:]
switch readFilterMode { switch readFilterMode {
case "allow": case "allow":
@@ -100,8 +111,6 @@ func (ws *WebServer) parseFilterPanics(fileName string) (FilterMode, []string) {
panic("invalid filter mode for " + fileName + ": use allow|deny") panic("invalid filter mode for " + fileName + ": use allow|deny")
} }
filter = filterLines[1:]
return filterMode, filter return filterMode, filter
} }