Skip to content

Commit

Permalink
ignore internal and server-relative url() in CSS (vercel/turborepo#4582)
Browse files Browse the repository at this point in the history
### Description

* ignore internal urls like `url(#noiseFilter)`
* ignore server-relative urls like `url(/foo)`

WEB-363
  • Loading branch information
sokra authored Apr 14, 2023
1 parent fcda11a commit 1eaea4b
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions crates/turbopack-css/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,24 @@ impl<'a> VisitAstPath for AssetReferencesVisitor<'a> {

let src = url_string(u);

let issue_span = u.span;
self.references.push(
UrlAssetReferenceVc::new(
self.origin,
RequestVc::parse(Value::new(src.to_string().into())),
AstPathVc::cell(as_parent_path(ast_path)),
IssueSourceVc::from_byte_offset(
self.source,
issue_span.lo.to_usize(),
issue_span.hi.to_usize(),
),
)
.into(),
);
// ignore internal urls like `url(#noiseFilter)`
// ignore server-relative urls like `url(/foo)`
if !matches!(src.bytes().next(), Some(b'#') | Some(b'/')) {
let issue_span = u.span;
self.references.push(
UrlAssetReferenceVc::new(
self.origin,
RequestVc::parse(Value::new(src.to_string().into())),
AstPathVc::cell(as_parent_path(ast_path)),
IssueSourceVc::from_byte_offset(
self.source,
issue_span.lo.to_usize(),
issue_span.hi.to_usize(),
),
)
.into(),
);
}

u.visit_children_with_path(self, ast_path);
}
Expand Down

0 comments on commit 1eaea4b

Please sign in to comment.