From f5e6d8d80c1736d0e44cc94b26d90b0a5694268a Mon Sep 17 00:00:00 2001 From: tom <62763456+amplitudesxd@users.noreply.github.com> Date: Wed, 29 Oct 2025 23:22:38 +0000 Subject: [PATCH] fix: extract metadata from document head (#2342) --- apps/api/native/src/html.rs | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/apps/api/native/src/html.rs b/apps/api/native/src/html.rs index d028ae78f..6d548c3a0 100644 --- a/apps/api/native/src/html.rs +++ b/apps/api/native/src/html.rs @@ -116,7 +116,14 @@ fn _extract_metadata(html: &str) -> Result, Box::new(); - if let Some(title) = document + let head_node = document + .select("head") + .map_err(|_| "Failed to select head")? + .next(); + + let search_root = head_node.as_ref().map(|h| h.as_node()).unwrap_or(&document); + + if let Some(title) = search_root .select("title") .map_err(|_| "Failed to select title")? .next() @@ -124,13 +131,13 @@ fn _extract_metadata(html: &str) -> Result, Box Result, Box