Fix URI captures matching empty segments (#264)

It was never the intention that `/:key` should match `/`. This fixes
that.

Part of https://github.com/tokio-rs/axum/issues/259
This commit is contained in:
David Pedersen
2021-08-24 18:27:06 +00:00
committed by GitHub
parent ab207af060
commit 0d2db387a8
3 changed files with 22 additions and 2 deletions
+1 -1
View File
@@ -762,7 +762,7 @@ impl PathPattern {
if let Some(key) = part.strip_prefix(':') {
capture_group_names.push(Bytes::copy_from_slice(key.as_bytes()));
Cow::Owned(format!("(?P<{}>[^/]*)", key))
Cow::Owned(format!("(?P<{}>[^/]+)", key))
} else {
Cow::Borrowed(part)
}