Fix the request transformer regex 68/13368/1
authoraravind.est <aravindhan.a@est.tech>
Thu, 19 Sep 2024 18:26:14 +0000 (19:26 +0100)
committeraravind.est <aravindhan.a@est.tech>
Thu, 19 Sep 2024 18:26:14 +0000 (19:26 +0100)
Request transformer regex fixed to match the continuous path parameters.

Issue-ID: NONRTRIC-1031
Change-Id: I6b7f0f2ffcfead5fc6f9541077cc262323813a5f
Signed-off-by: aravind.est <aravindhan.a@est.tech>
servicemanager/internal/publishserviceapi/typeupdate.go

index 72a987d..ac84c0d 100644 (file)
@@ -621,14 +621,14 @@ func deriveTransformPattern(routePattern string) (string, error) {
        }
 
        // Regular expression to match named capture groups
-       re := regexp.MustCompile(`/\(\?<([^>]+)>([^\/]+)/`)
+       re := regexp.MustCompile(`\(\?<([^>]+)>([^\/]+)`)
        // Find all matches in the route pattern
        matches := re.FindAllStringSubmatch(routePattern, -1)
 
        transformPattern := routePattern
        for _, match := range matches {
                // match[0] is the full match, match[1] is the capture group name, match[2] is the pattern
-               placeholder := fmt.Sprintf("/$(uri_captures[\"%s\"])/", match[1])
+               placeholder := fmt.Sprintf("$(uri_captures[\"%s\"])", match[1])
                // Replace the capture group with the corresponding placeholder
                transformPattern = strings.Replace(transformPattern, match[0], placeholder, 1)
        }