summaryrefslogtreecommitdiff
path: root/qml_plugin/src/web
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-08-05 21:06:26 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-08-05 21:06:26 +0800
commit7f3889f941cbfa0ed9517cf424ebec451da67b5f (patch)
tree8321fe3e408bee446f719a95b97163853cc4676e /qml_plugin/src/web
parentf20f6351c9929c27461e80ff21a48105e26e6cc2 (diff)
duckduckgo: filter empty as Option::None
Diffstat (limited to 'qml_plugin/src/web')
-rw-r--r--qml_plugin/src/web/duckduckgo.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/qml_plugin/src/web/duckduckgo.rs b/qml_plugin/src/web/duckduckgo.rs
index b87d5af..fcfa633 100644
--- a/qml_plugin/src/web/duckduckgo.rs
+++ b/qml_plugin/src/web/duckduckgo.rs
@@ -132,19 +132,24 @@ pub async fn query(input: &str) -> anyhow::Result<DuckDuckGoContent> {
DuckDuckGoContent {
title: resp
.heading
+ .filter(|h| !h.is_empty())
.unwrap_or(
resp.definition
+ .filter(|d| !d.is_empty())
.unwrap_or(alt_desc.clone()),
),
description_html: resp
.answer
+ .filter(|a| !a.is_empty())
.unwrap_or(
resp.r#abstract
+ .filter(|a| !a.is_empty())
.unwrap_or(alt_desc),
),
// TODO: try also Results[*].Icon.URL and RelatedTopics[*].Icon.URL
image: resp
.image
+ .filter(|i| !i.is_empty())
.and_then(
|i| {
if !i.is_empty() {