fix link when extracting the feed address

If the <link rel="alternate" href="..."/> was not the first
<link/> attribute under the <feed/> tag, the bad one was extracted
as the corresponding site URL.
db4
Samuel Tardieu 2011-12-14 23:18:26 +01:00 committed by Joe Groff
parent 46a00c4ce2
commit ddd7df2a38
2 changed files with 6 additions and 6 deletions

View File

@ -65,15 +65,14 @@ TUPLE: entry title url description date ;
[ "item" tags-named [ rss2.0-entry ] map set-entries ]
tri ;
: atom-entry-link ( tag -- url/f )
"link" tags-named
[ "rel" attr { f "alternate" } member? ] find nip
dup [ "href" attr >url ] when ;
: atom-link ( tag -- url/f )
"link" "alternate" "rel" tag-named-with-attr
[ "href" attr >url ] [ f ] if* ;
: atom1.0-entry ( tag -- entry )
<entry> swap {
[ "title" tag-named children>string >>title ]
[ atom-entry-link >>url ]
[ atom-link >>url ]
[
{ "content" "summary" } any-tag-named
dup children>> [ string? not ] any?
@ -90,7 +89,7 @@ TUPLE: entry title url description date ;
: atom1.0 ( xml -- feed )
<feed> swap
[ "title" tag-named children>string >>title ]
[ "link" tag-named "href" attr >url >>url ]
[ atom-link >>url ]
[ "entry" tags-named [ atom1.0-entry ] map set-entries ]
tri ;

View File

@ -7,6 +7,7 @@
</subtitle>
<updated>2005-07-31T12:29:29Z</updated>
<id>tag:example.org,2003:3</id>
<link rel="hub" href="https://pubsubhubbub.example.org/"/>
<link rel="alternate" type="text/html"
hreflang="en" href="http://example.org/"/>
<link rel="self" type="application/atom+xml"