Skip to content

Commit 7c804da

Browse files
committed
Make merge and merge! consistent
1 parent d300d6f commit 7c804da

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/secure_headers/headers/content_security_policy_config.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ def directive_value(directive)
5454
end
5555

5656
def merge(new_hash)
57-
ContentSecurityPolicy.combine_policies(self.to_h, new_hash)
57+
new_config = self.dup
58+
puts new_config.inspect
59+
new_config.send(:from_hash, new_hash)
60+
new_config
5861
end
5962

6063
def merge!(new_hash)

spec/lib/secure_headers_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ module SecureHeaders
391391

392392
hash = SecureHeaders.header_hash_for(request)
393393
expect(hash["Content-Security-Policy"]).to eq("default-src 'self'; script-src 'self'")
394-
expect(hash["Content-Security-Policy-Report-Only"]).to eq("default-src 'self'; script-src 'self' foo.com")
394+
expect(hash["Content-Security-Policy-Report-Only"]).to eq("default-src 'self'; script-src foo.com")
395395
end
396396

397397
it "allows you to opt-out of enforced CSP" do

0 commit comments

Comments
 (0)