Skip to content

Commit

Permalink
Merge pull request #2573 from AlchemyCMS/backport/6.1-stable/pr-2571
Browse files Browse the repository at this point in the history
[6.1-stable] Merge pull request #2571 from tvdeyen/fix-non-stupid-digest-assets
  • Loading branch information
tvdeyen committed Aug 29, 2023
2 parents 38e62d9 + d5119ee commit 2aa16ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/non_stupid_digest_assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def assets(assets)
def whitelisted_assets(assets)
assets.select do |logical_path, _digest_path|
whitelist.any? do |item|
item =~ logical_path
/#{item}/ =~ logical_path
end
end
end
Expand Down
8 changes: 7 additions & 1 deletion spec/libraries/non_stupid_digest_assets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
end

context "when the whitelist is not empty" do
it "returns the assets that match the whitelist" do
it "returns the assets that match the whitelist of regex" do
NonStupidDigestAssets.whitelist = [/foo/]
assets = { "foo.js" => "foo-123.js", "bar.js" => "bar-123.js" }
expect(NonStupidDigestAssets.assets(assets)).to eq("foo.js" => "foo-123.js")
end

it "returns the assets that match the whitelist of strings" do
NonStupidDigestAssets.whitelist = ["foo.js"]
assets = {"foo.js" => "foo-123.js", "bar.js" => "bar-123.js"}
expect(NonStupidDigestAssets.assets(assets)).to eq("foo.js" => "foo-123.js")
end
end
end
end

0 comments on commit 2aa16ae

Please sign in to comment.