From 1fba224a6646bff440ad74a5e54f9909f29cbd6f Mon Sep 17 00:00:00 2001 From: Fabiano Parente Date: Thu, 9 Jan 2025 07:25:30 -0300 Subject: [PATCH] MINOR: remove redundancy in AddCustomRoute function logic Refactors the `AddCustomRoute` function to eliminate redundancy introduced in commit c28d620a. The updated code removes repetition without add extra spaces. --- pkg/route/route.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pkg/route/route.go b/pkg/route/route.go index f8d94c4f..5178a7ff 100644 --- a/pkg/route/route.go +++ b/pkg/route/route.go @@ -108,17 +108,9 @@ func AddCustomRoute(route Route, routeACLAnn string, api api.HAProxyClient) (err } if route.Path.Path != "" { if route.Path.PathTypeMatch == store.PATH_TYPE_EXACT { - if routeCond == "" { - routeCond = fmt.Sprintf("{ path %s }", route.Path.Path) - } else { - routeCond = fmt.Sprintf("%s { path %s }", routeCond, route.Path.Path) - } + routeCond = fmt.Sprintf("%s{ path %s }", routeCond, route.Path.Path) } else { - if routeCond == "" { - routeCond = fmt.Sprintf("{ path -m beg %s }", route.Path.Path) - } else { - routeCond = fmt.Sprintf("%s { path -m beg %s }", routeCond, route.Path.Path) - } + routeCond = fmt.Sprintf("%s{ path -m beg %s }", routeCond, route.Path.Path) } } routeCond = fmt.Sprintf("%s { %s } ", routeCond, routeACLAnn)