Remove other places that use rfc2047 decoder
This commit is contained in:
@ -33,7 +33,6 @@
|
||||
"linkedom": "^0.14.16",
|
||||
"luxon": "^3.0.4",
|
||||
"puppeteer-core": "^19.1.1",
|
||||
"rfc2047": "^4.0.1",
|
||||
"underscore": "^1.13.6",
|
||||
"uuid": "^9.0.0"
|
||||
}
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import addressparser from 'addressparser'
|
||||
import rfc2047 from 'rfc2047'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import { parseHTML } from 'linkedom'
|
||||
import axios from 'axios'
|
||||
import { parseHTML } from 'linkedom'
|
||||
import { Browser } from 'puppeteer-core'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
|
||||
interface Unsubscribe {
|
||||
mailTo?: string
|
||||
@ -148,10 +147,9 @@ export abstract class ContentHandler {
|
||||
parseUnsubscribe(unSubHeader: string): Unsubscribe {
|
||||
// parse list-unsubscribe header
|
||||
// e.g. List-Unsubscribe: <https://omnivore.com/unsub>, <mailto:unsub@omnivore.com>
|
||||
const decoded = rfc2047.decode(unSubHeader)
|
||||
return {
|
||||
httpUrl: decoded.match(/<(https?:\/\/[^>]*)>/)?.[1],
|
||||
mailTo: decoded.match(/<mailto:([^>]*)>/)?.[1],
|
||||
httpUrl: unSubHeader.match(/<(https?:\/\/[^>]*)>/)?.[1],
|
||||
mailTo: unSubHeader.match(/<mailto:([^>]*)>/)?.[1],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -560,16 +560,6 @@ describe('Newsletter email test', () => {
|
||||
httpUrl
|
||||
)
|
||||
})
|
||||
|
||||
context('when unsubscribe header rfc2047 encoded', () => {
|
||||
it('returns mail to address if exists', () => {
|
||||
const header = `=?us-ascii?Q?=3Cmailto=3A654e9594-184c-4884-8e02-e6e58a3a6871+87e39b3d-c3ca-4be?= =?us-ascii?Q?b-ba4d-977cc2ba61e7+067a353f-f775-4f2c-?= =?us-ascii?Q?a5cc-978df38deeca=40unsub=2Ebeehiiv=2Ecom=3E=2C?= =?us-ascii?Q?_=3Chttps=3A=2F=2Fwww=2Emilkroad=2Ecom=2Fsubscribe=2F87e39b3d-c3ca-4beb-ba4d-97?= =?us-ascii?Q?7cc2ba61e7=2Fmanage=3Fpost=5Fid=3D067a353f-f775?= =?us-ascii?Q?-4f2c-a5cc-978df38deeca=3E?=',`
|
||||
|
||||
expect(new GenericHandler().parseUnsubscribe(header).mailTo).to.equal(
|
||||
'654e9594-184c-4884-8e02-e6e58a3a6871+87e39b3d-c3ca-4beb-ba4d-977cc2ba61e7+067a353f-f775-4f2c-a5cc-978df38deeca@unsub.beehiiv.com'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('preParse', () => {
|
||||
|
||||
Reference in New Issue
Block a user