Merge pull request #1423 from omnivore-app/fix/cloud-build-failure

fix: content-fetch-gcf cloud build failure
This commit is contained in:
Hongbo Wu
2022-11-16 11:12:55 +08:00
committed by GitHub
2 changed files with 5 additions and 3 deletions

View File

@ -6,11 +6,11 @@
"dependencies": {
"dotenv": "^8.2.0",
"express": "^4.17.1",
"@google-cloud/functions-framework": "^3.0.0",
"@omnivore/puppeteer-parse": "^1.0.0",
"@sentry/serverless": "^6.13.3"
},
"devDependencies": {
"@google-cloud/functions-framework": "^3.0.0",
"chai": "^4.3.6",
"mocha": "^10.0.0"
},

View File

@ -12,7 +12,6 @@ export class GitHubHandler extends ContentHandler {
async preParse(url: string, dom: Document): Promise<Document> {
const body = dom.querySelector('body')
const head = dom.querySelector('head')
const article = dom.querySelector('article')
const twitterTitle = dom.querySelector(`meta[name='twitter:title']`)
const linkAuthor = dom.querySelector(`span[itemprop='author']`)
@ -34,7 +33,10 @@ export class GitHubHandler extends ContentHandler {
// Remove the GitHub - and repo org from the title
const twitterTitleContent = twitterTitle?.getAttribute('content')
if (twitterTitle && twitterTitleContent) {
twitterTitle.setAttribute('content', twitterTitleContent.replace(/GitHub - .*\//, ''))
twitterTitle.setAttribute(
'content',
twitterTitleContent.replace(/GitHub - .*\//, '')
)
}
return Promise.resolve(dom)