diff --git a/webhooks/appmesh/gatewayroute_validator.go b/webhooks/appmesh/gatewayroute_validator.go index ec8cd1f3..f8fde890 100644 --- a/webhooks/appmesh/gatewayroute_validator.go +++ b/webhooks/appmesh/gatewayroute_validator.go @@ -193,8 +193,8 @@ func validateHTTPRouteRewrite(rewrite *appmesh.HTTPGatewayRouteRewrite, match ap return errors.New("Both prefix and path for rewrites cannot be specified. Only 1 allowed") } if rewrite.Prefix != nil { - if match.Prefix != nil && (!strings.HasSuffix(*match.Prefix, "/") || !strings.HasPrefix(*match.Prefix, "/")) { - return errors.New("Prefix to be matched on must start and end with '/'") + if match.Prefix != nil && !strings.HasPrefix(*match.Prefix, "/") { + return errors.New("Prefix to be matched on must start with '/'") } return validatePrefixRewrite(rewrite.Prefix) } diff --git a/webhooks/appmesh/gatewayroute_validator_test.go b/webhooks/appmesh/gatewayroute_validator_test.go index 1a40c503..86f564a6 100644 --- a/webhooks/appmesh/gatewayroute_validator_test.go +++ b/webhooks/appmesh/gatewayroute_validator_test.go @@ -340,18 +340,6 @@ func Test_gatewayRouteValidator_validateHTTPRouteRewrite(t *testing.T) { }, wantErr: errors.New("Both prefix and path for rewrites cannot be specified. Only 1 allowed"), }, - { - name: "Incorrect Prefix Match format", - match: appmesh.HTTPGatewayRouteMatch{ - Prefix: aws.String("/red"), - }, - rewrite: appmesh.HTTPGatewayRouteRewrite{ - Prefix: &appmesh.GatewayRoutePrefixRewrite{ - Value: aws.String("/test/"), - }, - }, - wantErr: errors.New("Prefix to be matched on must start and end with '/'"), - }, { name: "Incorrect Prefix Rewrite format", match: appmesh.HTTPGatewayRouteMatch{ @@ -374,7 +362,7 @@ func Test_gatewayRouteValidator_validateHTTPRouteRewrite(t *testing.T) { Value: aws.String("/test/"), }, }, - wantErr: errors.New("Prefix to be matched on must start and end with '/'"), + wantErr: errors.New("Prefix to be matched on must start with '/'"), }, { name: "Incorrect Prefix Rewrite format - case2",