whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Minor speedup
Date Fri, 08 Mar 2019 00:23:10 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 941c953  Minor speedup
941c953 is described below

commit 941c9536e08adbfbc1875c72a5e72c2895c56238
Author: Sebb <sebb@apache.org>
AuthorDate: Fri Mar 8 00:23:04 2019 +0000

    Minor speedup
---
 lib/whimsy/asf/mail.rb | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/whimsy/asf/mail.rb b/lib/whimsy/asf/mail.rb
index 87300d4..b55b47c 100644
--- a/lib/whimsy/asf/mail.rb
+++ b/lib/whimsy/asf/mail.rb
@@ -158,10 +158,12 @@ module ASF
     # The case of the name part is preserved since some providers may be case-sensitive
     # Almost all providers ignore case in names, however that is not guaranteed
     def self.to_canonical(email)
-      email.match %r{^([^@]+)@(.+)$} do |m|
-        name,dom = m.captures
+      parts = email.split('@')
+      if parts.length == 2
+        name, dom = parts
+        return email if name.length == 0 || dom.length == 0
         dom.downcase!
-        if dom.match %r{^(?:gmail|googlemail)\.com$}
+        if %w(gmail.com googlemail.com).include? dom
           return name.sub(/\+.*/,'').gsub('.','').downcase + '@' + dom
         else
           # only downcase the domain (done above)


Mime
View raw message