Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Sep 24, 2024
1 parent 6955d72 commit 05f1252
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/core/src/routing/filters/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl TryFrom<Vec<WispKind>> for CombWisp {
is_prev_named = true;
if wisp.0.starts_with('*') {
is_greedy = true;
let (star_mark, name) = crate::routing::split_greedy_name(&wisp.0);
let (star_mark, name) = crate::routing::split_wild_name(&wisp.0);
wild_regex = Some(
Regex::new(&format!("(?<{}>.*)", &regex::escape(name)))
.expect("regex should worked"),
Expand All @@ -360,7 +360,7 @@ impl TryFrom<Vec<WispKind>> for CombWisp {
is_prev_named = false;
if wisp.name.starts_with('*') {
is_greedy = true;
let (star_mark, name) = crate::routing::split_greedy_name(&wisp.name);
let (star_mark, name) = crate::routing::split_wild_name(&wisp.name);
wild_regex = Some(
Regex::new(&format!("(?<{}>.*)", &regex::escape(name)))
.expect("regex should work"),
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/routing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,15 @@ impl PathParams {
}
if name.starts_with('*') {
self.inner
.insert(split_greedy_name(name).1.to_owned(), value);
.insert(split_wild_name(name).1.to_owned(), value);
self.greedy = true;
} else {
self.inner.insert(name.to_owned(), value);
}
}
}

pub(crate) fn split_greedy_name(name: &str) -> (&str, &str) {
pub(crate) fn split_wild_name(name: &str) -> (&str, &str) {
if name.starts_with("*+") || name.starts_with("*?") || name.starts_with("**") {
(&name[0..2], &name[2..])
} else if let Some(stripped) = name.strip_prefix('*') {
Expand Down

0 comments on commit 05f1252

Please sign in to comment.