Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend: getSubjectFromRequestPath trim query suffix if present #1139

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading