From b062793a20d85382b34180c7c0f904ef6e0bb437 Mon Sep 17 00:00:00 2001 From: pwnwriter Date: Tue, 17 Oct 2023 21:24:31 +0545 Subject: [PATCH] chore(screenshot): print no title if url doesn't have one // closes #30 --- src/cli/screenshot.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cli/screenshot.rs b/src/cli/screenshot.rs index 095ab64..5b410ed 100644 --- a/src/cli/screenshot.rs +++ b/src/cli/screenshot.rs @@ -155,10 +155,14 @@ async fn take_screenshot( .await?; if !silent { - let title = page.get_title().await.unwrap_or_default().unwrap(); - show_info(url, title, res.status()); + match page.get_title().await { + Ok(Some(title)) => show_info(url.clone(), title, res.status()), + _ => { + let title = "No title".to_string(); + show_info(url.clone(), title, res.status()); + } + } } - page.close().await?; Ok(())