fix: [CODE-3440]: add fix for go get in cut out terminated path (#3618)

* fix: [CODE-3440]: add fix for go get in cut out terminated path
This commit is contained in:
Abhinav Singh 2025-04-02 21:29:22 +00:00 committed by Harness
parent d3261ebc20
commit 6b521d3422
2 changed files with 11 additions and 0 deletions

View File

@ -270,6 +270,10 @@ func regexPathTerminatedWithMarker(
// case 2: xxxxxxxxxxxxxxxxxxxxxxxxM/ (M is at the end and it should have a / after it)
// case 3: xxxxxxxxxxxxxxxxxxxxxxxxxM (M is at the end).
func cutOutTerminatedPath(subPath string, marker string) (string, bool) {
// base case of marker being empty
if marker == "" {
return subPath, true
}
endsWithSlash := strings.HasSuffix(marker, "/")
if !endsWithSlash {
marker += "/"

View File

@ -252,6 +252,13 @@ func TestCutOutTerminatedPath(t *testing.T) {
expectedPath: "",
expectedFound: true,
},
{
name: "empty marker",
subPath: "/foo/bar",
marker: "",
expectedPath: "/foo/bar",
expectedFound: true,
},
}
for _, tt := range tests {