diff --git a/app/api/middleware/encode/encode.go b/app/api/middleware/encode/encode.go index 1c0805fb1..2db6b6f5b 100644 --- a/app/api/middleware/encode/encode.go +++ b/app/api/middleware/encode/encode.go @@ -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 += "/" diff --git a/app/api/middleware/encode/encode_test.go b/app/api/middleware/encode/encode_test.go index 420a47556..a482e26e4 100644 --- a/app/api/middleware/encode/encode_test.go +++ b/app/api/middleware/encode/encode_test.go @@ -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 {