diff options
author | Eric Wong <e@80x24.org> | 2019-05-15 01:18:07 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-05-15 01:18:52 +0000 |
commit | 70caf43a131fc5bdf7104f82f2acee9d5353d6a8 (patch) | |
tree | 54691cbe7b16adf0fd8406d2a3a514bbd19741ce /lib/PublicInbox/SearchMsg.pm | |
parent | e981538130dd6d285392f4316328edbadab0d330 (diff) | |
download | public-inbox-70caf43a131fc5bdf7104f82f2acee9d5353d6a8.tar.gz |
www: use Inbox->over where appropriate
We don't need to rely on Xapian search functionality for the majority of the WWW code, even. subject_normalized is moved to SearchMsg, where it (probably) makes more sense, anyways.
Diffstat (limited to 'lib/PublicInbox/SearchMsg.pm')
-rw-r--r-- | lib/PublicInbox/SearchMsg.pm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/PublicInbox/SearchMsg.pm b/lib/PublicInbox/SearchMsg.pm index ceb6edad..5f3c8af8 100644 --- a/lib/PublicInbox/SearchMsg.pm +++ b/lib/PublicInbox/SearchMsg.pm @@ -8,6 +8,8 @@ package PublicInbox::SearchMsg; use strict; use warnings; +use base qw(Exporter); +our @EXPORT_OK = qw(subject_normalized); use PublicInbox::MID qw/mid_clean mid_mime/; use PublicInbox::Address; use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp); @@ -185,4 +187,16 @@ sub mid ($;$) { sub _extract_mid { mid_clean(mid_mime($_[0]->{mime})) } +our $REPLY_RE = qr/^re:\s+/i; + +sub subject_normalized ($) { + my ($subj) = @_; + $subj =~ s/\A\s+//s; # no leading space + $subj =~ s/\s+\z//s; # no trailing space + $subj =~ s/\s+/ /gs; # no redundant spaces + $subj =~ s/\.+\z//; # no trailing '.' + $subj =~ s/$REPLY_RE//igo; # remove reply prefix + $subj; +} + 1; |