From: Samuel Tardieu Date: Wed, 14 Dec 2011 22:18:26 +0000 (+0100) Subject: fix link when extracting the feed address X-Git-Tag: 0.97~3261 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=ddd7df2a3869e6258254980fdee26c4430696b38 fix link when extracting the feed address If the was not the first attribute under the tag, the bad one was extracted as the corresponding site URL. --- diff --git a/basis/syndication/syndication.factor b/basis/syndication/syndication.factor index 0cc124c088..407e09aab1 100644 --- a/basis/syndication/syndication.factor +++ b/basis/syndication/syndication.factor @@ -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 ) 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 ) 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 ; diff --git a/basis/syndication/test/atom.xml b/basis/syndication/test/atom.xml index d0195661ce..222c321189 100644 --- a/basis/syndication/test/atom.xml +++ b/basis/syndication/test/atom.xml @@ -7,6 +7,7 @@ 2005-07-31T12:29:29Z tag:example.org,2003:3 +