From ca03ba64a27d0d216063684f6f0b41be19e847a2 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Fri, 12 Apr 2019 16:20:50 -0500 Subject: [PATCH] strip out `` tags from the head --- src/utils/html.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/utils/html.rs b/src/utils/html.rs index a7fe2b41a..4c797d2c8 100644 --- a/src/utils/html.rs +++ b/src/utils/html.rs @@ -49,6 +49,27 @@ fn extract_from_rcdom(dom: &RcDom) -> Result<(Handle, Handle)> { let head = head.ok_or_else(|| err_msg("couldn't find tag in rustdoc output"))?; let body = body.ok_or_else(|| err_msg("couldn't find tag in rustdoc output"))?; + + { + head.children.borrow_mut().retain(|node| { + match node.data { + NodeData::Element { ref name, ref attrs, .. } => { + // `` is rustdoc's custom favicon, but we want to + // use our own, so ditch it so browsers request the favicon at the domain root + // instead + !(name.local == *"link" && + attrs.borrow() + .iter() + .any(|attr| { + attr.name.local == *"rel" && + &*attr.value == "shortcut icon" + })) + } + _ => true, + } + }); + } + Ok((head, body)) }