Skip to content

Commit

Permalink
Merge pull request #106 from extractus/7.0.3
Browse files Browse the repository at this point in the history
v7.0.3
  • Loading branch information
ndaidong authored Aug 22, 2023
2 parents 6fc2606 + f4ca7fe commit 5fa8ab8
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"devDependencies": {
"eslint": "^8.47.0",
"https-proxy-agent": "^7.0.1",
"jest": "^29.6.2",
"nock": "^13.3.2"
"jest": "^29.6.3",
"nock": "^13.3.3"
},
"keywords": [
"extractor",
Expand Down
17 changes: 17 additions & 0 deletions src/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,23 @@ describe('test extract() standard feed', () => {
})
expect(validateProps(result.entries[0])).toBe(true)
})

test('extract rss feed from medium.com (content:encoded)', async () => {
const url = 'https://medium.com/feed/@ameliakusiak'
const xml = readFileSync('test-data/medium-feed.xml', 'utf8')
const { baseUrl, path } = parseUrl(url)
nock(baseUrl).get(path).reply(200, xml, {
'Content-Type': 'application/xml',
})
const result = await extract(url)
feedAttrs.forEach((k) => {
expect(hasProperty(result, k)).toBe(true)
})
entryAttrs.forEach((k) => {
expect(hasProperty(result.entries[0], k)).toBe(true)
})
expect(validateProps(result.entries[0])).toBe(true)
})
})

describe('test extract() with `useISODateFormat` option', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/parseRssFeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ const transform = (item, options) => {
link = '',
pubDate = '',
description = '',
'content:encoded': content = '',
} = item

const published = useISODateFormat ? toISODateString(pubDate) : pubDate
const htmlContent = getText(content || description)
const entry = {
id: getEntryId(guid, link, pubDate),
title: getText(title),
link: getPureUrl(link, guid, baseUrl),
published,
description: buildDescription(description, descriptionMaxLen),
description: buildDescription(htmlContent || description, descriptionMaxLen),
}

const extraFields = getExtraEntryFields(item)
Expand Down
Loading

0 comments on commit 5fa8ab8

Please sign in to comment.