From bd54d55633dc9a9fb60f91aea3b0b193e45e1aef Mon Sep 17 00:00:00 2001 From: Andriy Rakhnin Date: Thu, 15 Aug 2024 17:20:10 +0200 Subject: [PATCH] couple of cosmetic changes --- src/html.rs | 10 +++++----- tests/html/embed_srcset.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/html.rs b/src/html.rs index 7a37de07..6a80626b 100644 --- a/src/html.rs +++ b/src/html.rs @@ -28,10 +28,10 @@ struct SrcSetItem<'a> { descriptor: &'a str, } -const WHITESPACES: &'static [char] = &['\t', '\n', '\x0c', '\r', ' ']; - const ICON_VALUES: &'static [&str] = &["icon", "shortcut icon"]; +const WHITESPACES: &'static [char] = &['\t', '\n', '\x0c', '\r', ' ']; + pub fn add_favicon(document: &Handle, favicon_data_url: String) -> RcDom { let mut buf: Vec = Vec::new(); serialize( @@ -177,7 +177,7 @@ pub fn embed_srcset( while offset < size { let mut has_descriptor = true; - // Zero or more ASCII whitespace + skip leading U+002C COMMA character (,) + // Zero or more whitespaces + skip leading comma let url_start = offset + srcset[offset..] .chars() @@ -186,7 +186,7 @@ pub fn embed_srcset( if url_start >= size { break; } - // A valid non-empty URL that does not start or end with a U+002C COMMA character (,) + // A valid non-empty URL that does not start or end with comma let mut url_end = url_start + srcset[url_start..] .chars() @@ -197,7 +197,7 @@ pub fn embed_srcset( url_end -= 1; } offset = url_end; - // If the URL wasn't terminated by a U+002C COMMA character (,) there may also be a descriptor. + // If the URL wasn't terminated by comma there may also be a descriptor if has_descriptor { offset += srcset[url_end..].chars().take_while(|&c| c != ',').count(); } diff --git a/tests/html/embed_srcset.rs b/tests/html/embed_srcset.rs index b83b035d..f382a6d9 100644 --- a/tests/html/embed_srcset.rs +++ b/tests/html/embed_srcset.rs @@ -135,7 +135,7 @@ mod passing { } #[test] - fn the_latest_without_descriptor() { + fn last_without_descriptor() { let cache = &mut HashMap::new(); let client = Client::new(); let srcset_value = "small,s.png 1x, medium,m.png 2x, large,l.png";