From fcc8b397172247a1fc58129f221689001a9ac978 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 22 Jun 2021 22:45:47 +0200 Subject: [PATCH] fix: ignore uri query for service pattern matching --- internal/config/service.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/config/service.go b/internal/config/service.go index da953c0..1b84dc7 100644 --- a/internal/config/service.go +++ b/internal/config/service.go @@ -45,7 +45,17 @@ type BraceCapture struct { // Match returns if this service would handle this HTTP request func (svc *Service) Match(req *http.Request) bool { - return req.Method == svc.Method && svc.matchPattern(req.RequestURI) + var ( + uri = req.RequestURI + queryIndex = strings.IndexByte(uri, '?') + ) + + // remove query part for matching the pattern + if queryIndex > -1 { + uri = uri[:queryIndex] + } + + return req.Method == svc.Method && svc.matchPattern(uri) } // checks if an uri matches the service's pattern