Browse Source

Found one more corner case!

master
Stephen Starkey 2 years ago
parent
commit
9522253bd9
  1. 8
      src/clj/email_counter/emails.clj
  2. 3
      test/clj/email_counter/test/emails.clj

8
src/clj/email_counter/emails.clj

@ -16,11 +16,9 @@
from the name portion. If the email is nil, we will simply return nil"
[email :- (s/maybe s/Str)]
(let [email (parse-email email)
[_ n d] (when email (re-matches #"^(.*?)(@[^@]+$)" email))]
(some-> n
(str/replace #"\." "")
(str/replace #"\+.*" "")
(str d))))
[_ n d] (when email (re-matches #"^(.*?)(@[^@]+$)" email))
n (some-> n (str/replace #"\." "") (str/replace #"\+.*" ""))]
(when-not (str/blank? n) (str n d))))
(s/defn unique-gmail-parsed-set :- #{s/Str}
"Given a bunch of email addresses, strip out the bits Gmail would have

3
test/clj/email_counter/test/emails.clj

@ -11,6 +11,7 @@
(are [expected given] (= expected (parse-email given))
nil nil
nil ""
"+wow@gmail.com" "+wow@gmail.com"
"me@here.com" "me@here.com "
"m.e@here.com" "\n\t m.e@here.com"
"me@here.com" "Me <me@here.com>"
@ -20,6 +21,7 @@
(are [expected given] (= expected (parse-for-gmail given))
nil nil
nil ""
nil "+wow@gmail.com"
"me@here.com" "me@here.com"
"me@here.com" "m.e@here.com"
"me@here.com" "me+you@here.com"
@ -37,5 +39,6 @@
"me+you@here.com"
"you@there.com"
"you+me@there.com"
"+wow@gmail.com"
""
nil]))))
Loading…
Cancel
Save