Case-insensitivity should be handled by the lookup functions instead of the callers.
Don't code on no sleep, folks
This commit is contained in:
parent
6bf7803b99
commit
3d69a6dd28
3 changed files with 4 additions and 3 deletions
|
@ -4,7 +4,7 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
pub fn query(database_path: PathBuf, handle: String) {
|
pub fn query(database_path: PathBuf, handle: String) {
|
||||||
let data = LookupHandler::load(database_path).unwrap();
|
let data = LookupHandler::load(database_path).unwrap();
|
||||||
let resource = data.lookup(handle.trim().to_lowercase().as_str()).unwrap();
|
let resource = data.lookup(handle.trim()).unwrap();
|
||||||
serde_json::to_writer_pretty(stdout(), resource).unwrap();
|
serde_json::to_writer_pretty(stdout(), resource).unwrap();
|
||||||
println!()
|
println!()
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,8 @@ impl LookupHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lookup_with_index(&self, resource_query: &str) -> Option<(usize, &Resource)> {
|
pub fn lookup_with_index(&self, resource_query: &str) -> Option<(usize, &Resource)> {
|
||||||
let resource_index = *self.lookup.get(resource_query)?;
|
let resource_query = resource_query.to_lowercase();
|
||||||
|
let resource_index = *self.lookup.get(resource_query.as_str())?;
|
||||||
let found_resource = &self.resources.0[resource_index];
|
let found_resource = &self.resources.0[resource_index];
|
||||||
debug!("Lookup for {resource_query} returned {found_resource:?}");
|
debug!("Lookup for {resource_query} returned {found_resource:?}");
|
||||||
Some((resource_index, found_resource))
|
Some((resource_index, found_resource))
|
||||||
|
|
|
@ -111,7 +111,7 @@ async fn run_webfinger_query(
|
||||||
let resource = datastore
|
let resource = datastore
|
||||||
.read()
|
.read()
|
||||||
.await
|
.await
|
||||||
.lookup(resource_query.to_lowercase().as_str())
|
.lookup(resource_query)
|
||||||
.ok_or(StatusCode::NOT_FOUND)?
|
.ok_or(StatusCode::NOT_FOUND)?
|
||||||
.clone();
|
.clone();
|
||||||
debug!("Found resource: {resource:?}");
|
debug!("Found resource: {resource:?}");
|
||||||
|
|
Loading…
Reference in a new issue