From a4ebb33cd5f61ae30b4925a89119f20d2ed02408 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sun, 1 Dec 2019 14:58:07 -0800 Subject: Trim spaces for RDF entry links --- reader/rdf/parser_test.go | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'reader/rdf/parser_test.go') diff --git a/reader/rdf/parser_test.go b/reader/rdf/parser_test.go index 4f3d033..87410f8 100644 --- a/reader/rdf/parser_test.go +++ b/reader/rdf/parser_test.go @@ -422,3 +422,67 @@ func TestParseFeedWithInvalidCharacterEntity(t *testing.T) { t.Errorf(`Incorrect URL, got: %q`, feed.SiteURL) } } + +func TestParseFeedWithURLWrappedInSpaces(t *testing.T) { + data := ` + + + bioRxiv Subject Collection: Bioengineering + http://biorxiv.org + + This feed contains articles for bioRxiv Subject Collection "Bioengineering" + + + + + + + + bioRxiv + + + + + bioRxiv + + http://biorxiv.org + + + + <![CDATA[ + Microscale Collagen and Fibroblast Interactions Enhance Primary Human Hepatocyte Functions in 3-Dimensional Models + ]]> + + + http://biorxiv.org/cgi/content/short/857789v1?rss=1 + + + + 2019-11-29 + doi:10.1101/857789 + + Cold Spring Harbor Laboratory + 2019-11-29 + + + ` + + feed, err := Parse(bytes.NewBufferString(data)) + if err != nil { + t.Fatal(err) + } + + if feed.SiteURL != "http://biorxiv.org" { + t.Errorf(`Incorrect URL, got: %q`, feed.SiteURL) + } + + if len(feed.Entries) != 1 { + t.Fatalf(`Unexpected number of entries, got %d`, len(feed.Entries)) + } + + if feed.Entries[0].URL != `http://biorxiv.org/cgi/content/short/857789v1?rss=1` { + t.Errorf(`Unexpected entry URL, got %q`, feed.Entries[0].URL) + } +} -- cgit v1.2.3