From 3bcb62d7caad1366dc697a97ec114e5e161caa93 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Wed, 14 Dec 2011 23:18:26 +0100 Subject: [PATCH] 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. --- basis/syndication/syndication.factor | 11 +++++------ basis/syndication/test/atom.xml | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) 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 +