diff options
author | Alex Legler <alex@a3li.li> | 2015-02-23 21:58:52 +0100 |
---|---|---|
committer | Alex Legler <alex@a3li.li> | 2015-02-23 21:58:52 +0100 |
commit | 496ba5a82637b8f023846f53d6c219d3e18259ad (patch) | |
tree | fef8a7a46c25cda84df262beec5880e529a1f0f3 /lib/helpers.rb | |
parent | All dates are UTC now, strip timezone (diff) | |
download | frontend-496ba5a82637b8f023846f53d6c219d3e18259ad.tar.gz frontend-496ba5a82637b8f023846f53d6c219d3e18259ad.tar.bz2 frontend-496ba5a82637b8f023846f53d6c219d3e18259ad.zip |
Various UI bit fixes for new storage format
Diffstat (limited to 'lib/helpers.rb')
-rw-r--r-- | lib/helpers.rb | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/helpers.rb b/lib/helpers.rb index 525dd93..5b4d2e3 100644 --- a/lib/helpers.rb +++ b/lib/helpers.rb @@ -42,8 +42,9 @@ helpers do ERB::Util::url_encode(text) end - def strip_email_domain(str) - str.split(/,\s*/).map do |email| + # This method strips domains from header fields. + def strip_email_headers(ary) + [ary].flatten.map do |email| email.gsub(/@(.*?)(>|$)/) do |s| if $1 == 'gentoo.org' "@g.o#{$2}" @@ -53,21 +54,20 @@ helpers do "@#{'×' * $1.length}#{$2}" end end - end.join(', ') + end end + # This method is meant to strip emails from free text, not header fields def strip_email(str) - 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 + str.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.join(', ') + end end def linkize(str) |