Skip to content

Commit

Permalink
backend: getSubjectFromRequestPath trim query suffix if present
Browse files Browse the repository at this point in the history
  • Loading branch information
bojand committed Feb 28, 2024
1 parent c6ac52d commit 115ca29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/pkg/api/handle_schema_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,9 @@ func getSubjectFromRequestPath(r *http.Request) string {
requestURI = strings.Replace(requestURI, r.Host, "", 1)
requestURI = strings.Replace(requestURI, "/api/schema-registry/subjects/", "", 1)
requestURI = strings.Replace(requestURI, "/api/schema-registry/config/", "", 1)
if r.URL.RawQuery != "" {
requestURI = strings.TrimSuffix(requestURI, "?"+r.URL.RawQuery)
}

// find the versions suffix of the path
subjectPart := requestURI
Expand Down
5 changes: 5 additions & 0 deletions backend/pkg/api/handle_schema_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func Test_getSubjectFromRequestPath(t *testing.T) {
target: "/api/schema-registry/subjects/with%252Fslash/versions/last",
expected: "with%2Fslash",
},
{
name: "with query",
target: "https://console-123.cn456.fmc.ppd.cloud.redpanda.com/api/schema-registry/subjects/repro?permanent=false",
expected: "repro",
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 115ca29

Please sign in to comment.