Skip to content
Merged
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
13 changes: 12 additions & 1 deletion src/api_type/bedrock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ fn extract_model_from_path(path: &str) -> Option<String> {
if model.is_empty() {
return None;
}
Some(model.to_owned())
let decoded = percent_encoding::percent_decode_str(model)
.decode_utf8_lossy()
.into_owned();
Some(decoded)
}

// Bedrock api url format : `/model/<model_id>/invoke[WithResponseStream]`
Expand Down Expand Up @@ -135,6 +138,14 @@ mod tests {
);
}

#[test]
fn extract_model_percent_decodes_segment() {
let arn =
"arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abcd1234567";
let encoded = "/model/arn%3Aaws%3Abedrock%3Aus-east-1%3A123456789012%3Aapplication-inference-profile%2Fabcd1234567/invoke";
assert_eq!(extract_model_from_path(encoded), Some(arn.to_owned()));
}

#[test]
fn extract_model_from_invalid_paths() {
assert_eq!(extract_model_from_path("/model//invoke"), None);
Expand Down
Loading