lib/mail/elements/message_ids_element.rb in mail-2.7.1 vs lib/mail/elements/message_ids_element.rb in mail-2.8.0.rc1
- old
+ new
@@ -1,22 +1,31 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/message_ids_parser'
+require 'mail/utilities'
module Mail
- class MessageIdsElement
+ class MessageIdsElement #:nodoc:
+ def self.parse(string)
+ new(string).tap(&:message_ids)
+ end
+
attr_reader :message_ids
def initialize(string)
- @message_ids = Mail::Parsers::MessageIdsParser.parse(string).message_ids.map { |msg_id| clean_msg_id(msg_id) }
+ @message_ids = parse(string)
end
def message_id
message_ids.first
end
private
- def clean_msg_id(val)
- val =~ /.*<(.*)>.*/ ? $1 : val
- end
+ def parse(string)
+ if Utilities.blank? string
+ []
+ else
+ Mail::Parsers::MessageIdsParser.parse(string).message_ids
+ end
+ end
end
end