diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2015-02-21 20:22:33 -0800 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2015-02-21 20:22:47 -0800 |
commit | 5a8cc4173b1544ed2ecc73191abceab2ad404d5a (patch) | |
tree | 43c945829cad349edabaefd69255157d21c38a7e | |
parent | and a slash (diff) | |
download | frontend-5a8cc4173b1544ed2ecc73191abceab2ad404d5a.tar.gz frontend-5a8cc4173b1544ed2ecc73191abceab2ad404d5a.tar.bz2 frontend-5a8cc4173b1544ed2ecc73191abceab2ad404d5a.zip |
Correctly handle multiple email addreses being handed to the cleanup function.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r-- | lib/helpers.rb | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/helpers.rb b/lib/helpers.rb index 3620d49..405975b 100644 --- a/lib/helpers.rb +++ b/lib/helpers.rb @@ -44,27 +44,31 @@ helpers do end def strip_email_domain(str) - str.gsub(/@(.*?)(>|$)/) do |s| - if $1 == 'gentoo.org' - "@g.o#{$2}" - elsif $1 == 'lists.gentoo.org' - "@l.g.o#{$2}" - else - "@#{'×' * $1.length}#{$2}" + str.split(/,\s*/).map do |email| + email.gsub(/@(.*?)(>|$)/) do |s| + if $1 == 'gentoo.org' + "@g.o#{$2}" + elsif $1 == 'lists.gentoo.org' + "@l.g.o#{$2}" + else + "@#{'×' * $1.length}#{$2}" + end end - end + end.join(', ') end def strip_email(str) - str.gsub(/([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+)\.([a-zA-Z]{2,10})/) do |email| - if $2 == 'gentoo' and $3 == 'org' - "#{$1}@g.o" - elsif $2 == 'lists.gentoo' and $3 == 'org' - "#{$1}@l.g.o" - else - "#{$1}@#{'×' * $2.length}.#{$3}" + str.split(/,\s*/).map do |email| + email.gsub(/([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+)\.([a-zA-Z]{2,10})/) do |s| + if $2 == 'gentoo' and $3 == 'org' + "#{$1}@g.o" + elsif $2 == 'lists.gentoo' and $3 == 'org' + "#{$1}@l.g.o" + else + "#{$1}@#{'×' * $2.length}.#{$3}" + end end - end + end.join(', ') end def linkize(str) |