Skip to content

Commit

Permalink
feat: don't prerender for Twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jan 6, 2024
1 parent ae2c84f commit e359aa0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
5 changes: 3 additions & 2 deletions scripts/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { writeFile } = require('fs').promises
const topsites = require('top-sites')

const domains = [
[['domain', 'abc.net.au']],
[['domainWithoutSuffix', 'apple']],
[['domainWithoutSuffix', 'bbc']],
[['domainWithoutSuffix', 'blogspot']],
Expand Down Expand Up @@ -43,14 +44,14 @@ const domains = [
[['domainWithoutSuffix', 'theguardian']],
[['domainWithoutSuffix', 'theverge']],
[['domainWithoutSuffix', 'tumblr']],
[['domainWithoutSuffix', 'twitter']],
[['domainWithoutSuffix', 'vimeo']],
[['domainWithoutSuffix', 'wikipedia']],
[['domainWithoutSuffix', 'wordpress']],
[['domainWithoutSuffix', 'ycombinator']],
[['domainWithoutSuffix', 'yelp']],
[['domainWithoutSuffix', 'youtube']],
[['domainWithoutSuffix', 'zoom']],
[['domain', 'abc.net.au']]
[['domainWithoutSuffix', 'zoom']]
]

const { top, rest } = reduce(
Expand Down
6 changes: 5 additions & 1 deletion test/is-fetch-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const { isFetchMode } = require('..')
test('true', t => {
const url =
'https://www.abc.net.au/news/2023-06-14/idpwd-2023-calling-all-budding-storytellers-with-disability/102388090'

t.true(isFetchMode(url))
})

test('false', t => {
const url = 'https://twitter.com/Kikobeats/status/1741205717636264436'
t.false(isFetchMode(url))
})
26 changes: 20 additions & 6 deletions test/prerender.js → test/mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,26 @@ test('`{ prerender: false }`', async t => {
})

test("`{ prerender: 'auto' }`", async t => {
const url = 'https://google.com'
const { stats } = await getHTML(url, {
getBrowserless,
puppeteerOpts: { adblock: false }
})
t.is(stats.mode, 'fetch')
{
const url = 'https://google.com'
const { stats } = await getHTML(url, {
getBrowserless,
puppeteerOpts: { adblock: false }
})
t.is(stats.mode, 'fetch')
}
{
const url = 'https://twitter.com/Kikobeats/status/1741205717636264436'
const { html, stats } = await getHTML(url, {
headers: {
'user-agent': 'Slackbot 1.0 (+https://api.slack.com/robots)'
},
getBrowserless,
puppeteerOpts: { adblock: false }
})
t.true(html.includes('og:description'))
t.is(stats.mode, 'fetch')
}
})

test.skip('prerender error fallback into fetch mode', async t => {
Expand Down

0 comments on commit e359aa0

Please sign in to comment.