Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got incomplete entry link when RSS <item> <link> is not full URL #468

Closed
wakenmeng opened this issue Oct 10, 2022 · 1 comment
Closed

Got incomplete entry link when RSS <item> <link> is not full URL #468

wakenmeng opened this issue Oct 10, 2022 · 1 comment

Comments

@wakenmeng
Copy link

wakenmeng commented Oct 10, 2022

Hello,
I recently added a new rss feed: https://darkcoding.net/index.xml, but its <link> of <item> is relative path, not full URL:

<item>
<title>Overthinking Leetcode's Two Sum with SIMD</title>
<link>/software/two-sum/</link>
<pubDate>Sun, 09 Oct 2022 00:00:00 -0700</pubDate>
<guid>/software/two-sum/</guid>
<description>
When is the linear scan Two Sum solution faster than a map? What if we use AVX-512 instructions?
</description>
</item>

As you can see the item link is /software/two-sum/, and the elfeed entry url in the elfeed-search page is also this subpath. So when I enter this entry, the content is only the <description> part, which didn't request the full url to get the whole page.

I've been searching and cannot find relative config. How can I fix this?

@wakenmeng wakenmeng changed the title How to handle when the value of <link> is not full URL. Got incomplete entry link when RSS <item> <link> is not full URL Oct 11, 2022
@wakenmeng
Copy link
Author

I am new to lisp, but I try to add a function to deal with the incomplete link, and the entry link is complete now, but the content page still only got description part, I guess I'm moving from elfeed-search to elfeed-show, and try to figure it out. I'm closing this cos it seems there's no relative config and I need to solve it myself.

diff --git a/elfeed.el b/elfeed.el
index bbfef26..28656da 100644
--- a/elfeed.el
+++ b/elfeed.el
@@ -334,6 +334,12 @@ If PROTOCOL is nil, returns URL."
                       :email (match-string 1 clean)))
         (list (list :email clean))))))

+(defun elfeed--fixup-host (host url)
+  "Prepend host to URL if it is a path, starts with a single slash"
+  (if (and host url (string-match-p "^/[^//]" url))
+      (concat "//" host url)
+      url))
+
 (defun elfeed-entries-from-rss (url xml)
   "Turn parsed RSS content into a list of elfeed-entry structs."
   (let* ((feed-id url)
@@ -347,9 +353,9 @@ If PROTOCOL is nil, returns URL."
     (cl-loop for item in (xml-query-all* (rss channel item) xml) collect
              (let* ((title (or (xml-query* (title *) item) ""))
                     (guid (xml-query* (guid *) item))
-                    (link (elfeed--fixup-protocol
-                           protocol
-                           (or (xml-query* (link *) item) guid)))
+                    (link (elfeed--fixup-protocol protocol
+                               (elfeed--fixup-host namespace
+                                         (or (xml-query* (link *) item) guid))))
                     (date (or (xml-query* (pubDate *) item)
                               (xml-query* (date *) item)))
                     (authors (nconc (elfeed--rss-author-to-plist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant