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:
@ -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
|
||||
|
||||
@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user