Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore internal and server-relative url() in CSS #4582

Merged
merged 2 commits into from
Apr 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Server-relative URLs don't have any special behavior?

What about absolute URLs?

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