Skip to content

Commit

Permalink
Merge pull request #20 from ProspectiveCo/svg-inline-support
Browse files Browse the repository at this point in the history
Add `svg` inline support
  • Loading branch information
texodus authored Jul 4, 2024
2 parents ea5be4c + fdca500 commit e1f156b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/transformers/inline_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ fn into_data_uri<'a>(path: &Path) -> Option<Cow<'a, str>> {
let contents = read_file_sync(path)?;
let encoded = base64::encode(contents);
let fff = path.extension().unwrap_or_default().to_string_lossy();
let ggg = path.to_string_lossy();
let fmt = match fff.as_ref() {
"png" => "png",
_ => "svg+xml",
"gif" => "gif",
"svg" => "svg+xml",
x => ggg.as_ref(),
};

Some(format!("url(\"data:image/{};base64,{}\")", fmt, encoded).into())
Expand Down

0 comments on commit e1f156b

Please sign in to comment.