plugin/rewrite: pre-compile CNMAE rewrite regexp (#7697)

This commit changes the CNAME rewrite rule to use a pre-compiled regexp
when the match type is RegexMatch instead of compiling it on-the-fly for
each request. This will also allow for invalid regexp patterns to be
identified during setup instead of causing a panic when the rule is
first invoked.

Signed-off-by: Charlie Vieth <charlie.vieth@gmail.com>
This commit is contained in:
Charlie Vieth
2025-11-19 22:27:29 -05:00
committed by GitHub
parent e56971b253
commit 2883b6340f
2 changed files with 11 additions and 3 deletions

View File

@@ -33,6 +33,7 @@ func TestParse(t *testing.T) {
}`, true, "must begin with a name rule"},
{`rewrite stop`, true, ""},
{`rewrite continue`, true, ""},
{`rewrite stop name regex [bad[ bar answer name bar foo`, true, ""},
}
for i, test := range tests {