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: Work-round to match names like: 'John (Fred)'
Date Fri, 26 Feb 2021 11:39:39 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 5e5ef06  Work-round to match names like: 'John (Fred)'
5e5ef06 is described below

commit 5e5ef06970e8417a849ff3969791bb3857df3abb
Author: Sebb <sebb@apache.org>
AuthorDate: Fri Feb 26 11:39:30 2021 +0000

    Work-round to match names like: 'John (Fred)'
---
 www/members/nominations.cgi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/www/members/nominations.cgi b/www/members/nominations.cgi
index 26a4009..aba6508 100755
--- a/www/members/nominations.cgi
+++ b/www/members/nominations.cgi
@@ -93,7 +93,9 @@ _html do
           _ul nominations.sort_by {|nominee| nominee[:name]} do |nominee|
             _li! do
               person = ASF::Person.find(nominee[:id])
-              match = /\b(#{Regexp.escape(nominee[:name]||'')}|#{Regexp.escape(person.public_name||'')})\b/i
+              # N.B. \b does not match if it follows ')', so won't match John (Fred)
+              # TODO: Work-round is to also look for EOS, but this needs to be improved
+              match = /\b(#{Regexp.escape(nominee[:name]||'')}|#{Regexp.escape(person.public_name||'')})(\b|$)/i
 
               if emails.any? {|mail| mail.subject.downcase =~ match}
                 _a.present person.public_name, href: "#{ROSTER}/#{nominee[:id]}"
@@ -132,7 +134,9 @@ _html do
               href = MBOX + mail.date.strftime('%Y%m') + '.mbox/' +
               ERB::Util.url_encode('<' + mail.message_id + '>')
 
-              if nominees.any? {|name| mail.subject =~ /\b#{Regexp.escape(name)}\b/i}
+              # N.B. \b does not match if it follows ')', so won't match John (Fred)
+              # TODO: Work-round is to also look for EOS, but this needs to be improved
+              if nominees.any? {|name| mail.subject =~ /\b#{Regexp.escape(name)}(\b|$)/i}
                 _a.present mail.subject, href: href
               else
                 _a.missing mail.subject, href: href


Mime
View raw message