mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-04 21:37:58 +03:00
Fix: segments could be lost in case of immediate match
This commit is contained in:
parent
84112304a8
commit
fe73511576
5 changed files with 44 additions and 4 deletions
|
@ -1,5 +1,9 @@
|
|||
# Changes
|
||||
|
||||
## [0.5.1] - 2021-08-23
|
||||
|
||||
* Fix: segments could be lost in case of immediate match
|
||||
|
||||
## [0.5.0] - 2021-06-27
|
||||
|
||||
* Use ntex-bytes instead of bytestring
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "ntex-router"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
authors = ["ntex contributors <team@ntex.rs>"]
|
||||
description = "Path router"
|
||||
keywords = ["ntex"]
|
||||
|
|
|
@ -224,6 +224,7 @@ impl Tree {
|
|||
_ => continue,
|
||||
};
|
||||
if check(v, resource) {
|
||||
resource.resource_path().segments = segments;
|
||||
return Some(v);
|
||||
}
|
||||
}
|
||||
|
@ -255,6 +256,7 @@ impl Tree {
|
|||
_ => continue,
|
||||
};
|
||||
if check(v, resource) {
|
||||
resource.resource_path().segments = segments;
|
||||
return Some(v);
|
||||
}
|
||||
}
|
||||
|
@ -293,6 +295,7 @@ impl Tree {
|
|||
_ => continue,
|
||||
};
|
||||
if check(v, resource) {
|
||||
resource.resource_path().segments = segments;
|
||||
return Some(v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "ntex"
|
||||
version = "0.4.0-b.2"
|
||||
version = "0.4.0-b.3"
|
||||
authors = ["ntex contributors <team@ntex.rs>"]
|
||||
description = "Framework for composable network services"
|
||||
readme = "README.md"
|
||||
|
@ -45,7 +45,7 @@ http-framework = ["h2", "http", "httparse",
|
|||
[dependencies]
|
||||
ntex-codec = "0.5.0"
|
||||
ntex-rt = "0.2.2"
|
||||
ntex-router = "0.5.0"
|
||||
ntex-router = "0.5.1"
|
||||
ntex-service = "0.1.9"
|
||||
ntex-macros = "0.1.3"
|
||||
ntex-util = "0.1.1"
|
||||
|
@ -74,7 +74,7 @@ async-channel = "1.6.1"
|
|||
# http/web framework
|
||||
h2 = { version = "0.3", optional = true }
|
||||
http = { version = "0.2", optional = true }
|
||||
httparse = { version = "1.4.1", optional = true }
|
||||
httparse = { version = "1.5.1", optional = true }
|
||||
httpdate = { version = "1.0", optional = true }
|
||||
encoding_rs = { version = "0.8", optional = true }
|
||||
mime = { version = "0.3", optional = true }
|
||||
|
|
|
@ -958,6 +958,39 @@ mod tests {
|
|||
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
|
||||
}
|
||||
|
||||
#[crate::rt_test]
|
||||
async fn test_scope_variable_segment2() {
|
||||
let srv = init_service(App::new().service(web::scope("/ab-{project}").service(
|
||||
web::resource(["", "/"]).to(|r: HttpRequest| async move {
|
||||
HttpResponse::Ok()
|
||||
.body(format!("project: {}", &r.match_info()["project"]))
|
||||
}),
|
||||
)))
|
||||
.await;
|
||||
|
||||
let req = TestRequest::with_uri("/ab-project1").to_request();
|
||||
let resp = srv.call(req).await.unwrap();
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
|
||||
if let ResponseBody::Body(Body::Bytes(ref b)) = resp.response().body() {
|
||||
let bytes: Bytes = b.clone();
|
||||
assert_eq!(bytes, Bytes::from_static(b"project: project1"));
|
||||
}
|
||||
|
||||
let req = TestRequest::with_uri("/ab-project1/").to_request();
|
||||
let resp = srv.call(req).await.unwrap();
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
|
||||
if let ResponseBody::Body(Body::Bytes(ref b)) = resp.response().body() {
|
||||
let bytes: Bytes = b.clone();
|
||||
assert_eq!(bytes, Bytes::from_static(b"project: project1"));
|
||||
}
|
||||
|
||||
let req = TestRequest::with_uri("/aa-project1").to_request();
|
||||
let resp = srv.call(req).await.unwrap();
|
||||
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
|
||||
}
|
||||
|
||||
#[crate::rt_test]
|
||||
async fn test_nested_scope() {
|
||||
let srv = init_service(App::new().service(web::scope("/app").service(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue