prettier
This commit is contained in:
@ -57,7 +57,9 @@ export function emailsServiceRouter() {
|
||||
title: data.subject,
|
||||
content: data.html,
|
||||
author: data.from,
|
||||
url: (await findNewsletterUrl(data.html)) || 'https://omnivore.app/no_url',
|
||||
url:
|
||||
(await findNewsletterUrl(data.html)) ||
|
||||
'https://omnivore.app/no_url',
|
||||
})
|
||||
res.status(200).send('Newsletter')
|
||||
return
|
||||
|
||||
@ -402,7 +402,9 @@ export const isProbablyNewsletter = (html: string): boolean => {
|
||||
|
||||
// Given an HTML blob tries to find a URL to use for
|
||||
// a canonical URL.
|
||||
export const findNewsletterUrl = async (html: string): Promise<string | undefined> => {
|
||||
export const findNewsletterUrl = async (
|
||||
html: string
|
||||
): Promise<string | undefined> => {
|
||||
const dom = new JSDOM(html).window
|
||||
|
||||
// If there is an <h1 element with a URL, use that
|
||||
@ -416,8 +418,8 @@ export const findNewsletterUrl = async (html: string): Promise<string | undefine
|
||||
method: 'HEAD',
|
||||
url: href,
|
||||
})
|
||||
.then(res => res.request.res.responseUrl)
|
||||
.catch((e) => href)
|
||||
.then((res) => res.request.res.responseUrl as string | undefined)
|
||||
.catch((e) => href)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user