From c544dadd55b3f96d0f488d0c3e4266ae9f15d71f Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 24 Feb 2024 13:47:03 +0100 Subject: [PATCH] Fix categories import from Thunderbird's OPML Thunderbird OPML exports are looking like this: ```xml Thunderbird OPML Export - RSS Sat, 24 Feb 2024 11:31:13 GMT ... ... ``` This commit make it so that categories are now correctly imported. --- internal/reader/opml/parser.go | 2 +- internal/reader/opml/parser_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/reader/opml/parser.go b/internal/reader/opml/parser.go index 5e3fd0d2..09455a69 100644 --- a/internal/reader/opml/parser.go +++ b/internal/reader/opml/parser.go @@ -37,7 +37,7 @@ func getSubscriptionsFromOutlines(outlines opmlOutlineCollection, category strin CategoryName: category, }) } else if outline.Outlines.HasChildren() { - subscriptions = append(subscriptions, getSubscriptionsFromOutlines(outline.Outlines, outline.Text)...) + subscriptions = append(subscriptions, getSubscriptionsFromOutlines(outline.Outlines, outline.GetTitle())...) } } return subscriptions diff --git a/internal/reader/opml/parser_test.go b/internal/reader/opml/parser_test.go index c1d2ca5b..e2e2d143 100644 --- a/internal/reader/opml/parser_test.go +++ b/internal/reader/opml/parser_test.go @@ -129,10 +129,10 @@ func TestParseOpmlVersion1(t *testing.T) { Wed, 13 Mar 2019 11:51:41 GMT - + - + @@ -140,8 +140,8 @@ func TestParseOpmlVersion1(t *testing.T) { ` var expected SubcriptionList - expected = append(expected, &Subcription{Title: "Feed 1", FeedURL: "http://example.org/feed1/", SiteURL: "http://example.org/1", CategoryName: ""}) - expected = append(expected, &Subcription{Title: "Feed 2", FeedURL: "http://example.org/feed2/", SiteURL: "http://example.org/2", CategoryName: ""}) + expected = append(expected, &Subcription{Title: "Feed 1", FeedURL: "http://example.org/feed1/", SiteURL: "http://example.org/1", CategoryName: "Category 1"}) + expected = append(expected, &Subcription{Title: "Feed 2", FeedURL: "http://example.org/feed2/", SiteURL: "http://example.org/2", CategoryName: "Category 2"}) subscriptions, err := Parse(bytes.NewBufferString(data)) if err != nil { @@ -250,7 +250,7 @@ func TestParseOpmlWithInvalidCharacterEntity(t *testing.T) { ` var expected SubcriptionList - expected = append(expected, &Subcription{Title: "Feed 1", FeedURL: "http://example.org/feed1/a&b", SiteURL: "http://example.org/c&d", CategoryName: ""}) + expected = append(expected, &Subcription{Title: "Feed 1", FeedURL: "http://example.org/feed1/a&b", SiteURL: "http://example.org/c&d", CategoryName: "Feed 1"}) subscriptions, err := Parse(bytes.NewBufferString(data)) if err != nil {