From d4c3558b97a0b2ea1ddca5cd2808c440b8b95eea Mon Sep 17 00:00:00 2001 From: Awiteb Date: Sun, 11 Aug 2024 09:26:47 +0000 Subject: [PATCH] fix: Return `None` if the key not found and not `Some(None)` Signed-off-by: Awiteb --- src/finder/form_finder.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/finder/form_finder.rs b/src/finder/form_finder.rs index 23c593e..1840f27 100644 --- a/src/finder/form_finder.rs +++ b/src/finder/form_finder.rs @@ -62,15 +62,15 @@ impl CaptchaFinder for CaptchaFormFinder { async fn find_token(&self, req: &mut Request) -> Option> { req.form_data() .await - .map(|form| form.fields.get(&self.token_name).cloned()) .ok() + .and_then(|form| form.fields.get(&self.token_name).cloned().map(Some)) } async fn find_answer(&self, req: &mut Request) -> Option> { req.form_data() .await - .map(|form| form.fields.get(&self.answer_name).cloned()) .ok() + .and_then(|form| form.fields.get(&self.answer_name).cloned().map(Some)) } }