From d7fcdec712accc212bcfa35e50ade1233eb9beb3 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 15 Aug 2015 09:28:32 +0000 Subject: extract redundant Message-ID handling code Quit repeating ourselves and use a common MID module instead. --- lib/PublicInbox/Hval.pm | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'lib/PublicInbox/Hval.pm') diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm index 68f89546..d8b31c84 100644 --- a/lib/PublicInbox/Hval.pm +++ b/lib/PublicInbox/Hval.pm @@ -8,6 +8,7 @@ use warnings; use fields qw(raw href); use Encode qw(find_encoding); use URI::Escape qw(uri_escape_utf8); +use PublicInbox::MID qw/mid_clean mid_compressed/; my $enc_ascii = find_encoding('us-ascii'); @@ -25,16 +26,8 @@ sub new { sub new_msgid { my ($class, $msgid) = @_; - $msgid =~ s/\A\s*?\s*\z//; - - if (length($msgid) <= 40) { - $class->new($msgid); - } else { - require Digest::SHA; - my $hex = Digest::SHA::sha1_hex($msgid); - $class->new($msgid, $hex); - } + $msgid = mid_clean($msgid); + $class->new($msgid, mid_compressed($msgid)); } sub new_oneline { -- cgit v1.2.3-24-ge0c7