Seperate elements in NoTLSRedirectLocations by comma

This commit is contained in:
Alvaro Aleman 2018-03-18 10:35:16 +01:00
parent 467ff9924c
commit b727e1aeb4
No known key found for this signature in database
GPG key ID: D9D78F2AEF6D1EDF
3 changed files with 10 additions and 10 deletions

View file

@ -487,8 +487,8 @@ type Configuration struct {
// SyslogPort port
SyslogPort int `json:"syslog-port",omitempty`
// NoTLSRedirectLocations is a "\n -" seperated list of locations
// that shall not get redirected to tls
// NoTLSRedirectLocations is a comma-seperated list of locations
// that should not get redirected to TLS
NoTLSRedirectLocations string `json:"no-tls-redirect-locations"`
}

View file

@ -515,10 +515,10 @@ func isLocationInLocationList(location interface{}, rawLocationList string) bool
return false
}
locationList := strings.Split(rawLocationList, "\n- ")
locationList := strings.Split(rawLocationList, ",")
for _, locationListItem := range locationList {
locationListItem = strings.TrimLeft(locationListItem, "- ")
locationListItem = strings.Trim(locationListItem, " ")
if locationListItem == "" {
continue
}

View file

@ -462,12 +462,12 @@ func TestIsLocationInLocationList(t *testing.T) {
rawLocationList string
expected bool
}{
{&ingress.Location{Path: "/match"}, "- /match", true},
{&ingress.Location{Path: "/match"}, "\n- /match", true},
{&ingress.Location{Path: "/match"}, "- /dontmatch", false},
{&ingress.Location{Path: "/match"}, "\n- /dontmatch", false},
{&ingress.Location{Path: "/match"}, "- /dontmatch\n- /match", true},
{&ingress.Location{Path: "/match"}, "\n- /dontmatch\n- /dontmatcheither", false},
{&ingress.Location{Path: "/match"}, "/match", true},
{&ingress.Location{Path: "/match"}, ",/match", true},
{&ingress.Location{Path: "/match"}, "/dontmatch", false},
{&ingress.Location{Path: "/match"}, ",/dontmatch", false},
{&ingress.Location{Path: "/match"}, "/dontmatch,/match", true},
{&ingress.Location{Path: "/match"}, "/dontmatch,/dontmatcheither", false},
}
for _, testCase := range testCases {