diff options
author | Kyle Meyer <kyle@kyleam.com> | 2020-08-27 23:19:20 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2020-08-28 23:05:56 -0400 |
commit | 22ba165220a7041b331c860cb6dfdca237f59799 (patch) | |
tree | a8ee0d3312399c1fafbad74a53f3d5105855d74a /piem.el | |
parent | 673811ea1b2285059ab36e09c42682cd2d21686f (diff) | |
download | piem-22ba165220a7041b331c860cb6dfdca237f59799.tar.gz |
elfeed, eww: Be stricter about the returned message ID
Using the second group in piem-link-re is not reliable because the
trailing part of the URL may be anything. Instead get the inboxes
:url first and then generate a regular expression that has that value
as the prefix.
Message-Id: <20200828031920.7515-5-kyle@kyleam.com>
Diffstat (limited to 'piem.el')
-rw-r--r-- | piem.el | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -255,18 +255,20 @@ Functions should accept one argument, the message ID given to (defun piem--ensure-trailing-slash (s) (if (string-match-p ".+/\\'" s) s (concat s "/"))) -(defvar piem-link-re - (rx "/" (group (one-or-more (not (any "/" "\n")))) - "/" (group (one-or-more (not (any "/" "\n")))) - "/" (group (zero-or-one - (or "raw" - "t.mbox.gz" - (and (or "t" "T") "/#" - (one-or-more (not (any "/" "\n"))))))) - string-end) - "Regular expression matching public-inbox HTTP link. -The first group is the inbox, the second is the message ID, and -the rest is any trailing endpoint.") +(defun piem-message-link-re (url &optional mid) + "Return a regular expression matching a public-inbox url. +URL should be the top-level url for the inbox. If MID is +non-nil, make the match specific for that message." + (rx-to-string + `(and ,(piem--ensure-trailing-slash url) + (group ,(or mid + '(one-or-more (not (any "/" "\n"))))) + "/" (group (zero-or-one + (or "raw" + "t.mbox.gz" + (and (or "t" "T") "/#" + (one-or-more (not (any "/" "\n"))))))) + string-end))) (defun piem-inbox-by-header-match () "Return inbox based on matching message headers. |