Module: Mailmate::MidUrl
- Defined in:
- lib/mailmate/mid_url.rb
Overview
Build URLs that point to a single MailMate message:
- `mid:%3C<id>%3E` — local MailMate driver URL (RFC 2392). Selects
the message in the local store; what
`mm-modify` uses to drive the UI.
- `message://%3C<id>%3E` — portable, cross-machine reference. Same
encoding, different scheme. Resolves to the
same physical email on any MailMate install
because the RFC `Message-ID` header is
globally unique.
Both schemes need the angle brackets that wrap a Message-ID to be
percent-encoded; characters that would break URL parsers ([, ],
whitespace) are also encoded. Other URL-reserved characters (@, .,
-, _) are preserved — MailMate's parser accepts them as-is.
Class Method Summary collapse
-
.encoded_with_brackets(message_id) ⇒ Object
Percent-encoded
%3C…%3Eenvelope shared by both schemes. -
.for(message_id) ⇒ Object
mid:%3C<message-id>%3E— used by MailMate to select a message locally. -
.message_url_for(message_id) ⇒ Object
message://%3C<message-id>%3E— portable cross-machine reference.
Class Method Details
.encoded_with_brackets(message_id) ⇒ Object
Percent-encoded %3C…%3E envelope shared by both schemes. Exposed in
case a caller wants the brackets-only form without a scheme prefix.
36 37 38 39 40 41 |
# File 'lib/mailmate/mid_url.rb', line 36 def self.encoded_with_brackets() raise ArgumentError, "Message-ID required" if .nil? || .to_s.empty? id = .to_s.sub(/\A</, "").sub(/>\z/, "") encoded = id.gsub(/[\[\]<>\s]/) { |c| "%%%02X" % c.ord } "%3C#{encoded}%3E" end |
.for(message_id) ⇒ Object
mid:%3C<message-id>%3E — used by MailMate to select a message locally.
23 24 25 |
# File 'lib/mailmate/mid_url.rb', line 23 def self.for() "mid:#{encoded_with_brackets()}" end |
.message_url_for(message_id) ⇒ Object
message://%3C<message-id>%3E — portable cross-machine reference. Pass
back to EmlLookup.resolve_id (or any CLI that takes an id) to look up
the same physical email on another machine.
30 31 32 |
# File 'lib/mailmate/mid_url.rb', line 30 def self.() "message://#{encoded_with_brackets()}" end |