Skip to content

Commit

Permalink
couple of cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rakhnin committed Aug 15, 2024
1 parent 03fd21a commit bd54d55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> = Vec::new();
serialize(
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/html/embed_srcset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit bd54d55

Please sign in to comment.