Skip to content

Commit 1e36a7e

Browse files
committed
fix: clear existing query params if provided by middleware
1 parent 5c9451b commit 1e36a7e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/models/middleware/types/transform.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ impl Middleware for JoltTransformMiddleware {
136136
}
137137
if let Some(uri) = td_obj.get("uri").and_then(|v| v.as_str()) {
138138
target.uri = uri.to_string();
139+
// If the new URI contains query params, clear existing query_params
140+
// to avoid duplication when full_url() appends them
141+
if uri.contains('?') {
142+
target.query_params.clear();
143+
}
139144
}
140145
if let Some(base_url) = td_obj.get("base_url").and_then(|v| v.as_str()) {
141146
target.base_url = base_url.to_string();
@@ -148,6 +153,8 @@ impl Middleware for JoltTransformMiddleware {
148153
}
149154
}
150155
if let Some(query_params) = td_obj.get("query_params").and_then(|v| v.as_object()) {
156+
// Replace existing query_params entirely (not merge)
157+
target.query_params.clear();
151158
for (k, v) in query_params {
152159
if let Some(s) = v.as_str() {
153160
target.query_params.insert(k.clone(), vec![s.to_string()]);

0 commit comments

Comments
 (0)