Use Trim(Prefix/Suffix) instead of Trim(Left/Right) in rewrite prefix plugin (#2364) (#2372)

This commit is contained in:
Daniel Garcia
2018-12-06 16:10:46 -06:00
committed by Miek Gieben
parent fc667b98e0
commit 4a3f5cc41e
2 changed files with 38 additions and 23 deletions

View File

@@ -80,7 +80,7 @@ func (rule *prefixNameRule) Rewrite(ctx context.Context, state request.Request)
// Rewrite rewrites the current request when the name ends with the matching string.
func (rule *suffixNameRule) Rewrite(ctx context.Context, state request.Request) Result {
if strings.HasSuffix(state.Name(), rule.Suffix) {
state.Req.Question[0].Name = strings.TrimRight(state.Name(), rule.Suffix) + rule.Replacement
state.Req.Question[0].Name = strings.TrimSuffix(state.Name(), rule.Suffix) + rule.Replacement
return RewriteDone
}
return RewriteIgnored