@metascraper/helpers 5.43.4 → 5.43.7

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/index.js +10 -3
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -11,6 +11,7 @@ const _normalizeUrl = require('normalize-url')
11
11
  const smartquotes = require('smartquotes')
12
12
  const { decodeHTML } = require('entities')
13
13
  const iso6393 = require('iso-639-3/to-1')
14
+ const dataUri = require('data-uri-utils')
14
15
  const hasValues = require('has-values')
15
16
  const chrono = require('chrono-node')
16
17
  const isIso = require('isostring')
@@ -375,11 +376,17 @@ const $jsonld = propName => $ => {
375
376
 
376
377
  const image = (value, opts) => {
377
378
  const urlValue = url(value, opts)
378
- return urlValue !== undefined &&
379
+
380
+ const result =
381
+ urlValue !== undefined &&
379
382
  !isAudioUrl(urlValue, opts) &&
380
383
  !isVideoUrl(urlValue, opts)
381
- ? urlValue
382
- : undefined
384
+ ? urlValue
385
+ : undefined
386
+
387
+ if (!dataUri.test(result)) return result
388
+ const buffer = dataUri.toBuffer(dataUri.normalize(result))
389
+ return buffer.length ? result : undefined
383
390
  }
384
391
 
385
392
  const logo = image
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@metascraper/helpers",
3
3
  "description": "Collection of helper functions used by metascraper",
4
4
  "homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-helpers",
5
- "version": "5.43.4",
5
+ "version": "5.43.7",
6
6
  "main": "index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -25,6 +25,7 @@
25
25
  "audio-extensions": "0.0.0",
26
26
  "chrono-node": "~2.7.4",
27
27
  "condense-whitespace": "~2.0.0",
28
+ "data-uri-utils": "~1.0.7",
28
29
  "entities": "~4.5.0",
29
30
  "file-extension": "~4.0.5",
30
31
  "has-values": "~2.0.1",
@@ -62,5 +63,5 @@
62
63
  "publishConfig": {
63
64
  "access": "public"
64
65
  },
65
- "gitHead": "158c7d6e6c7a351d0a81529808af97f03f7e8bdf"
66
+ "gitHead": "9a22b5bf54e2cb7465c38191dd927128d9cf2706"
66
67
  }