diff options
| author | Fuwn <[email protected]> | 2022-04-01 02:45:15 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-04-01 02:45:15 -0700 |
| commit | f9eec315d8745a1bb0d4de9b811bd4cea4006d9d (patch) | |
| tree | 3a19fc3d42ee8a804accdcb2107a296674f64da3 /src | |
| parent | feat(pages): update gemini.gmi (diff) | |
| download | locus-f9eec315d8745a1bb0d4de9b811bd4cea4006d9d.tar.xz locus-f9eec315d8745a1bb0d4de9b811bd4cea4006d9d.zip | |
fix(database): always use trailing slash root
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 4c3d33b..74f613f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,21 +93,26 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { url.to_string(), ); - let previous_database = (*DATABASE.lock().unwrap()).get::<i32>(url.path()); + let mut url_path = url.path(); + if url.path().is_empty() { + url_path = "/"; + } + + let previous_database = (*DATABASE.lock().unwrap()).get::<i32>(url_path); match previous_database { None => { (*DATABASE.lock().unwrap()) - .set::<i32>(url.path(), &0) + .set::<i32>(url_path, &0) .unwrap(); } Some(_) => {} } - let new_database = (*DATABASE.lock().unwrap()).get::<i32>(url.path()); + let new_database = (*DATABASE.lock().unwrap()).get::<i32>(url_path); (*DATABASE.lock().unwrap()) - .set(url.path(), &(new_database.unwrap() + 1)) + .set(url_path, &(new_database.unwrap() + 1)) .unwrap(); })); router.set_error_handler(Box::new(|_| { |