commit: 5a8cc4173b1544ed2ecc73191abceab2ad404d5a Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> AuthorDate: Sun Feb 22 04:22:33 2015 +0000 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> CommitDate: Sun Feb 22 04:22:47 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/ag-web.git;a=commit;h=5a8cc417
Correctly handle multiple email addreses being handed to the cleanup function. Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> --- lib/helpers.rb | 36 ++++++++++++++++++++---------------- 1 file 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)