@browserless/goto 10.9.11 → 10.9.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +14 -7
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@browserless/goto",
3
3
  "description": "Go to a page aborting unnecessary requests",
4
4
  "homepage": "https://browserless.js.org/#/?id=gotopage-options",
5
- "version": "10.9.11",
5
+ "version": "10.9.13",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -64,5 +64,5 @@
64
64
  "timeout": "2m",
65
65
  "workerThreads": false
66
66
  },
67
- "gitHead": "01e4b9a320e1f0f7a7005710e1eec841fed917b6"
67
+ "gitHead": "e969604e95ff461609d38cabfd0c58adf30102da"
68
68
  }
package/src/index.js CHANGED
@@ -326,6 +326,8 @@ module.exports = ({ defaultDevice = 'Macbook Pro 13', timeout: globalTimeout, ..
326
326
  const headersKeys = Object.keys(headers)
327
327
 
328
328
  if (headersKeys.length > 0) {
329
+ const { cookie, ...headersWithoutCookie } = headers
330
+
329
331
  if (headers.cookie) {
330
332
  const cookies = parseCookies(url, headers.cookie)
331
333
  prePromises.push(
@@ -337,6 +339,9 @@ module.exports = ({ defaultDevice = 'Macbook Pro 13', timeout: globalTimeout, ..
337
339
  )
338
340
  }
339
341
 
342
+ const extraHTTPHeaders = headers.cookie ? headersWithoutCookie : headers
343
+ const extraHTTPHeadersKeys = Object.keys(extraHTTPHeaders)
344
+
340
345
  if (headers['user-agent']) {
341
346
  prePromises.push(
342
347
  run({
@@ -347,13 +352,15 @@ module.exports = ({ defaultDevice = 'Macbook Pro 13', timeout: globalTimeout, ..
347
352
  )
348
353
  }
349
354
 
350
- prePromises.push(
351
- run({
352
- fn: page.setExtraHTTPHeaders(headers),
353
- timeout: actionTimeout,
354
- debug: { headers: headersKeys }
355
- })
356
- )
355
+ if (extraHTTPHeadersKeys.length > 0) {
356
+ prePromises.push(
357
+ run({
358
+ fn: page.setExtraHTTPHeaders(extraHTTPHeaders),
359
+ timeout: actionTimeout,
360
+ debug: { headers: extraHTTPHeadersKeys }
361
+ })
362
+ )
363
+ }
357
364
  }
358
365
 
359
366
  if (timezone) {