fix crash

This commit is contained in:
Mylloon 2024-12-14 02:24:24 +01:00
parent c200cbe07a
commit d0caa08819
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -203,8 +203,9 @@ fn fix_headers_ids(html: &str) -> String {
html, html,
RewriteStrSettings { RewriteStrSettings {
element_content_handlers: vec![element!("a[href^='#']", |el| { element_content_handlers: vec![element!("a[href^='#']", |el| {
el.set_attribute("href", &format!("#{}", el.get_attribute("id").unwrap())) if let Some(id) = el.get_attribute("id") {
.unwrap(); el.set_attribute("href", &format!("#{id}")).unwrap();
};
Ok(()) Ok(())
})], })],
..RewriteStrSettings::default() ..RewriteStrSettings::default()