@browserless/goto 9.5.0 → 9.5.4

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.
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": "9.5.0",
5
+ "version": "9.5.4",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -68,5 +68,5 @@
68
68
  "timeout": "2m",
69
69
  "verbose": true
70
70
  },
71
- "gitHead": "2efe5725e9b370366303e2ffc3d377436689d221"
71
+ "gitHead": "35ba31743c44f3a844ac831bbbc365e6f1cf961a"
72
72
  }
package/src/engine.bin CHANGED
Binary file
package/src/index.js CHANGED
@@ -14,6 +14,8 @@ const isUrl = require('is-url-http')
14
14
  const path = require('path')
15
15
  const fs = require('fs')
16
16
 
17
+ const truncate = (str, n = 80) => (str.length > n ? str.substr(0, n - 1) + '…' : str)
18
+
17
19
  const EVASIONS = require('./evasions')
18
20
 
19
21
  const ALL_EVASIONS_KEYS = Object.keys(EVASIONS)
@@ -224,13 +226,14 @@ module.exports = ({
224
226
  await page.setRequestInterception(true)
225
227
  page.on('request', req => {
226
228
  if (req.isInterceptResolutionHandled()) return
227
-
228
229
  const resourceType = req.resourceType()
230
+ const url = truncate(req.url())
231
+
229
232
  if (!abortTypes.includes(resourceType)) {
230
- debug('continue', { url: req.url(), resourceType })
233
+ debug('continue', { url, resourceType })
231
234
  return req.continue(req.continueRequestOverrides(), 0)
232
235
  }
233
- debug('abort', { url: req.url(), resourceType })
236
+ debug('abort', { url, resourceType })
234
237
  return req.abort('blockedbyclient', 0)
235
238
  })
236
239
  }