Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/goto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@browserless/devices": "^5.18.5",
"@cliqz/adblocker-puppeteer": "~1.5.0",
"debug-logfmt": "~1.0.4",
"got": "~9.6.0",
"got": "~10.4.0",
"p-reflect": "~2.1.0",
"p-timeout": "~3.2.0",
"tldts": "~5.6.3"
Expand Down
11 changes: 3 additions & 8 deletions packages/goto/scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ const writeFile = promisify(fs.writeFile)

const OUTPUT_FILENAME = 'src/engine.bin'

// Small helpers to allow fetching different types of data with `got`
const fetchBuffer = async url => (await got(url, { encoding: null })).body
const fetchText = async url => Buffer.from(await fetchBuffer(url), 'ascii')
const fetchJson = async url => JSON.parse(await fetchText(url))

// Lightweight `fetch` polyfill on top of `got` to allow consumption by adblocker
const fetch = url =>
Promise.resolve({
text: () => fetchText(url),
arrayBuffer: () => fetchBuffer(url),
json: () => fetchJson(url)
text: () => got(url),
arrayBuffer: () => got(url).buffer(),
json: () => got(url).json()
})

const main = async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/screenshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
],
"dependencies": {
"@browserless/goto": "^5.22.0",
"got": "~9.6.0",
"got": "~10.4.0",
"is-url-http": "~1.2.4",
"p-reflect": "~2.1.0",
"sharp": "~0.24.0",
Expand Down
5 changes: 1 addition & 4 deletions packages/screenshot/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ const BROWSER_THEMES = {
}

const getBackground = async (bg = 'transparent') => {
if (isHttpUrl(bg)) {
const { body } = await got(bg, { encoding: null })
return body
}
if (isHttpUrl(bg)) return got(bg).buffer()

if (!bg.includes('gradient')) {
bg = `linear-gradient(45deg, ${bg} 0%, ${bg} 100%)`
Expand Down