Skip to content

Commit

Permalink
Fix link feed item xml resolver
Browse files Browse the repository at this point in the history
Signed-off-by: m4rc3l05 <15786310+M4RC3L05@users.noreply.github.com>
  • Loading branch information
M4RC3L05 committed May 19, 2024
1 parent 767bfe5 commit 1980f54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/resolvers/xml-feed-resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ describe("resolver()", () => {
"foo",
);

assertEquals(
resolver({}, [{ link: { "@href": "foo" } }])
.items[0].link,
"foo",
);

assertEquals(
resolver({}, [{ link: { "@rel": "alternate", "@url": "foo" } }])
.items[0].link,
Expand Down
5 changes: 1 addition & 4 deletions src/resolvers/xml-feed-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ const resolveFeedItemEnclosures = (feedItem: Record<string, unknown>) =>
const resolveFeedItemLink = (feedItem: Record<string, unknown>) =>
["link"]
.flatMap((path) => _.get(feedItem, path))
.filter((value) =>
typeof value === "string" || (_.isObject(value) && "#text" in value) ||
_.get(value, "@rel") === "alternate"
)
.filter((value) => typeof value === "string" || _.isObject(value))
.map((value) =>
typeof value === "string"
? value
Expand Down

0 comments on commit 1980f54

Please sign in to comment.