Skip to content

Commit

Permalink
apply suggestions from review
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpdrsn committed Nov 8, 2022
1 parent 29a4d33 commit e4e9507
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions axum/src/extract/matched_path.rs
Expand Up @@ -139,9 +139,9 @@ pub(crate) fn set_matched_path_for_request(

let matched_path = append_nested_matched_path(matched_path, extensions);

if matched_path.contains(NEST_TAIL_PARAM_CAPTURE) {
if matched_path.ends_with(NEST_TAIL_PARAM_CAPTURE) {
extensions.insert(MatchedNestedPath(matched_path));
debug_assert!(extensions.remove::<MatchedPath>().is_none());
debug_assert!(matches!(dbg!(extensions.remove::<MatchedPath>()), None));
} else {
extensions.insert(MatchedPath(matched_path));
extensions.remove::<MatchedNestedPath>();
Expand All @@ -155,13 +155,11 @@ fn append_nested_matched_path(matched_path: &Arc<str>, extensions: &http::Extens
.map(|matched_path| matched_path.as_str())
.or_else(|| Some(&extensions.get::<MatchedNestedPath>()?.0))
{
let previous = if let Some(previous) = previous.strip_suffix(NEST_TAIL_PARAM_CAPTURE) {
previous
} else {
previous
};
let previous = previous
.strip_suffix(NEST_TAIL_PARAM_CAPTURE)
.unwrap_or(previous);

let matched_path = format!("{}{}", previous, matched_path);
let matched_path = format!("{previous}{matched_path}");
matched_path.into()
} else {
Arc::clone(matched_path)
Expand Down

0 comments on commit e4e9507

Please sign in to comment.