diff --git a/lib/non_stupid_digest_assets.rb b/lib/non_stupid_digest_assets.rb index e338499f27..033acdcb02 100644 --- a/lib/non_stupid_digest_assets.rb +++ b/lib/non_stupid_digest_assets.rb @@ -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 diff --git a/spec/libraries/non_stupid_digest_assets_spec.rb b/spec/libraries/non_stupid_digest_assets_spec.rb index 8593f54b52..6c2bbf1812 100644 --- a/spec/libraries/non_stupid_digest_assets_spec.rb +++ b/spec/libraries/non_stupid_digest_assets_spec.rb @@ -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