lib/site-inspector/checks/headers.rb in site-inspector-3.1.1 vs lib/site-inspector/checks/headers.rb in site-inspector-3.2.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + class SiteInspector class Endpoint class Headers < Check # TODO: kill this def strict_transport_security? @@ -42,24 +44,24 @@ xss_protection == '1; mode=block' end # Returns an array of hashes of downcased key/value header pairs (or an empty hash) def all - @all ||= (response && response.headers) ? Hash[response.headers.map { |k, v| [k.downcase, v] }] : {} + @all ||= response&.headers ? response.headers.transform_keys(&:downcase) : {} end - alias_method :headers, :all + alias headers all def [](header) headers[header] end def to_h { strict_transport_security: strict_transport_security || false, - content_security_policy: content_security_policy || false, - click_jacking_protection: click_jacking_protection || false, - server: server, - xss_protection: xss_protection || false + content_security_policy: content_security_policy || false, + click_jacking_protection: click_jacking_protection || false, + server: server, + xss_protection: xss_protection || false } end end end end