From 47951bb186f166de176b1c74ee0ca629ccdad531 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 17 May 2024 17:11:32 -0700 Subject: [PATCH] Protect against missing references --- lib/propshaft/compiler/css_asset_urls.rb | 2 +- test/fixtures/assets/first_path/dependent/b.css | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/propshaft/compiler/css_asset_urls.rb b/lib/propshaft/compiler/css_asset_urls.rb index de8a950..5e9a737 100644 --- a/lib/propshaft/compiler/css_asset_urls.rb +++ b/lib/propshaft/compiler/css_asset_urls.rb @@ -13,7 +13,7 @@ def referenced_by(asset, references: Set.new) asset.content.scan(ASSET_URL_PATTERN).each do |referenced_asset_url, _| referenced_asset = load_path.find(resolve_path(asset.logical_path.dirname, referenced_asset_url)) - unless references.include?(referenced_asset) + if referenced_asset && references.exclude?(referenced_asset) references << referenced_asset references.merge referenced_by(referenced_asset, references: references) end diff --git a/test/fixtures/assets/first_path/dependent/b.css b/test/fixtures/assets/first_path/dependent/b.css index 5a89d0f..084de15 100644 --- a/test/fixtures/assets/first_path/dependent/b.css +++ b/test/fixtures/assets/first_path/dependent/b.css @@ -1 +1,2 @@ -@import url('c.css') \ No newline at end of file +@import url('c.css') +@import url('missing.css')