Skip to content
Open
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
6 changes: 1 addition & 5 deletions autumn/src/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1826,11 +1826,7 @@ fn build_request(
// Use the same full segment encoder the typed path helpers use, so an
// MCP call accepts the same values a direct HTTP caller could pass.
let encoded = if is_catch_all {
value
.split('/')
.map(crate::paths::encode_path_segment)
.collect::<Vec<_>>()
.join("/")
crate::paths::encode_catch_all_param(&value)
} else {
crate::paths::encode_path_segment(&value)
};
Expand Down
32 changes: 20 additions & 12 deletions autumn/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,26 @@ pub fn encode_path_segment(value: impl std::fmt::Display) -> String {
#[must_use]
pub fn encode_catch_all_param(value: impl std::fmt::Display) -> String {
let s = value.to_string();
s.split('/')
.map(|segment| {
if segment == "." {
"%2E".to_string()
} else if segment == ".." {
"%2E%2E".to_string()
} else {
percent_encode(segment)
}
})
.collect::<Vec<String>>()
.join("/")
let mut out = String::with_capacity(s.len() + s.len() / 4);
let mut iter = s.split('/').map(|segment| {
if segment == "." {
"%2E".to_string()
} else if segment == ".." {
"%2E%2E".to_string()
} else {
percent_encode(segment)
}
});

if let Some(first) = iter.next() {
out.push_str(&first);
for item in iter {
out.push('/');
out.push_str(&item);
}
}

out
}

/// Percent-encode a query component per RFC 3986.
Expand Down
Loading