From 71ffc180036088d310714ca3d960b6378290a809 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 18 Apr 2019 18:01:33 -0700 Subject: rust: API lower-cases DOI lookups --- rust/src/endpoint_handlers.rs | 6 ++++-- rust/tests/test_api_server_http.rs | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'rust') diff --git a/rust/src/endpoint_handlers.rs b/rust/src/endpoint_handlers.rs index d9bd3403..f43b3559 100644 --- a/rust/src/endpoint_handlers.rs +++ b/rust/src/endpoint_handlers.rs @@ -277,10 +277,12 @@ impl Server { jstor_id, ) { (Some(doi), None, None, None, None, None, None, None) => { - check_doi(doi)?; + // DOIs always stored lower-case; lookups are case-insensitive + let doi = doi.to_lowercase(); + check_doi(&doi)?; release_ident::table .inner_join(release_rev::table) - .filter(release_rev::doi.eq(doi)) + .filter(release_rev::doi.eq(&doi)) .filter(release_ident::is_live.eq(true)) .filter(release_ident::redirect_id.is_null()) .first(conn)? diff --git a/rust/tests/test_api_server_http.rs b/rust/tests/test_api_server_http.rs index 66f36a14..c891ed2e 100644 --- a/rust/tests/test_api_server_http.rs +++ b/rust/tests/test_api_server_http.rs @@ -362,6 +362,17 @@ fn test_lookups() { Some("bigger example"), ); + // not lower-case + helpers::check_http_response( + request::get( + "http://localhost:9411/v0/release/lookup?doi=10.123/ABC", + headers.clone(), + &router, + ), + status::Ok, + Some("bigger example"), + ); + // URL encoded helpers::check_http_response( request::get( -- cgit v1.2.3