From 5fea03221efee68c48e73f6ceac001aa92bd13b3 Mon Sep 17 00:00:00 2001 From: Christopher Vollick <0@psycoti.ca> Date: Tue, 27 May 2025 12:05:59 -0400 Subject: [PATCH] Fixup dkim_headers Two here, first is a variable shadowing error because I used `h` in the map, and also the `each_with_object`. I now use `s` on the outside. Second is that while `[x].flatten.compact` seemed to do what I wanted, it seems like `Array(x)` does _nearly_ the same thing. One important difference between the two is how `Array` works if `x` is a hash, but in my case it's not, so for my purposes they're the same. Cleaner! --- lib/interac_email.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/interac_email.rb b/lib/interac_email.rb index a25804d52f677ce11b457b5e828c9e48f27dd13a..1b06d370785e775de690fa49c48ba934df8f9071 100644 --- a/lib/interac_email.rb +++ b/lib/interac_email.rb @@ -143,8 +143,9 @@ class InteracEmail def dkim_headers # Apparently there can sometimes be multiple DKIM sigs # And this library returns a scalar if there's one, or array otherwise - [@m["DKIM-Signature"]].flatten.compact.map { |h| - h.value + # This Array method, when passed `nil` even returns an emtpy list! + Array(@m["DKIM-Signature"]).map { |s| + s.value &.split(/;\s*/) &.each_with_object({}) { |f, h| k, v = f.split("=", 2)