Accept empty path as a valid path

This commit is contained in:
Ricardo Pchevuzinske Katz 2023-01-08 18:25:14 -03:00
parent cd9e774a73
commit b550d65943
2 changed files with 8 additions and 2 deletions

View file

@ -37,9 +37,9 @@ const (
var (
// pathAlphaNumeric is a regex validation of something like "^/[a-zA-Z]+$" on path
pathAlphaNumeric = regexp.MustCompile("^/[" + alphaNumericChars + "]*$").MatchString
pathAlphaNumeric = regexp.MustCompile("^[/" + alphaNumericChars + "]*$").MatchString
// pathRegexEnabled is a regex validation of paths that may contain regex.
pathRegexEnabled = regexp.MustCompile("^/[" + alphaNumericChars + regexEnabledChars + "]*$").MatchString
pathRegexEnabled = regexp.MustCompile("^[/" + alphaNumericChars + regexEnabledChars + "]*$").MatchString
)
func GetRemovedHosts(rucfg, newcfg *ingress.Configuration) []string {

View file

@ -158,6 +158,12 @@ func TestIsSafePath(t *testing.T) {
path string
want bool
}{
{
name: "should accept empty path",
want: true,
copyIng: generateDumbIngressforPathTest(false),
path: "",
},
{
name: "should accept valid path with regex disabled",
want: true,