Skip to content

Commit

Permalink
refactor: 🎨 add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
stormslowly committed Dec 23, 2024
1 parent 4c42ffc commit a20eea6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/mako/src/visitors/css_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ impl VisitMut for CSSAssets {
box UrlValue::Raw(s) => s.value.to_string(),
};

if is_remote_or_data_or_hash(&url) {
if is_remote_or_data_or_hash(&url) || url.is_empty() {
return;
}

let url = remove_first_tilde(url);

if url.is_empty() {
return;
}
let dep = Dependency {
source: url,
resolve_as: None,
Expand Down Expand Up @@ -114,6 +112,14 @@ mod tests {
);
}

#[test]
fn test_empty_url() {
assert_eq!(
run(r#".foo { background: url("") }"#),
r#".foo{background:url("")}"#
);
}

#[test]
fn test_big_image() {
assert!(run(r#".foo { background: url(big.jpg) }"#).contains(".foo{background:url(big."));
Expand Down

0 comments on commit a20eea6

Please sign in to comment.