From 4520c7c110102a4b734cec51246d357ac19b4bea Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 18 Feb 2020 18:43:49 -0600 Subject: [PATCH] syndication: Property can be present but f, handle this. Test case: "http://www.spreaker.com/show/2952221/episodes/feed" http-get nip parse-feed --- basis/syndication/syndication.factor | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/basis/syndication/syndication.factor b/basis/syndication/syndication.factor index 3bd22eb54a..74198c36a4 100644 --- a/basis/syndication/syndication.factor +++ b/basis/syndication/syndication.factor @@ -26,6 +26,9 @@ TUPLE: entry title url description date ; : try-parsing-timestamp ( string -- timestamp ) [ rfc822>timestamp ] [ drop rfc3339>timestamp ] recover ; +: ?children>string ( tag -- str/f ) + dup [ children>string ] when ; inline + : rss1.0-entry ( tag -- entry ) swap { [ "title" tag-named children>string >>title ] @@ -47,12 +50,12 @@ TUPLE: entry title url description date ; : rss2.0-entry ( tag -- entry ) swap { - [ "title" tag-named children>string >>title ] - [ { "link" "guid" } any-tag-named children>string >url >>url ] - [ { "description" "encoded" } any-tag-named children>string >>description ] + [ "title" tag-named ?children>string >>title ] + [ { "link" "guid" } any-tag-named ?children>string >url >>url ] + [ { "description" "encoded" } any-tag-named ?children>string >>description ] [ { "date" "pubDate" } any-tag-named - children>string try-parsing-timestamp >>date + ?children>string try-parsing-timestamp >>date ] } cleave ;