Merge pull request #1821 from omnivore-app/fix/times-of-india

Fix sometimes there is extra spaces between sender and email address by checking only the email address
This commit is contained in:
Hongbo Wu
2023-02-17 22:31:59 +08:00
committed by GitHub
2 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import { ContentHandler } from '../content-handler'
import addressparser from 'addressparser'
export class IndiaTimesHandler extends ContentHandler {
constructor() {
@ -13,7 +14,9 @@ export class IndiaTimesHandler extends ContentHandler {
dom: Document
}): Promise<boolean> {
return Promise.resolve(
input.from === 'The Times of India <newsletters@timesofindia.com>'
addressparser(input.from).some(
(e) => e.address === 'newsletters@timesofindia.com'
)
)
}

View File

@ -362,7 +362,7 @@ describe('Newsletter email test', () => {
const html = load('./test/data/india-times-newsletter.html')
const handler = await getNewsletterHandler({
html,
from: 'The Times of India <newsletters@timesofindia.com>',
from: 'The Times of India <newsletters@timesofindia.com>',
headers: {},
})
expect(handler).to.be.instanceOf(IndiaTimesHandler)