Merge pull request #1638 from omnivore-app/fix/no-author-in-newsletter

Fix the error when no name in subscription by using the email address as the author when no author found in the newsletter
This commit is contained in:
Hongbo Wu
2023-01-10 12:49:53 +08:00
committed by GitHub
2 changed files with 6 additions and 1 deletions

View File

@ -134,7 +134,7 @@ export abstract class ContentHandler {
// e.g. 'Jackson Harper from Omnivore App <jacksonh@substack.com>'
// or 'Mike Allen <mike@axios.com>'
const parsed = addressparser(from)
if (parsed.length > 0) {
if (parsed.length > 0 && parsed[0].name) {
return parsed[0].name
}
return from

View File

@ -93,6 +93,11 @@ describe('Newsletter email test', () => {
const from = 'Mike Allen <mike@axios.com>'
expect(new AxiosHandler().parseAuthor(from)).to.equal('Mike Allen')
})
it('returns email address if author is not there', () => {
const from = 'mike@axios.com'
expect(new AxiosHandler().parseAuthor(from)).to.equal(from)
})
})
describe('getNewsletterHandler', () => {