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

[7.0-stable] Merge pull request #2571 from tvdeyen/fix-non-stupid-digest-assets #2572

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
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
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