metascraper 5.58.5 → 5.58.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/package.json +3 -3
  2. package/src/get-data.js +8 -1
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "metascraper",
3
3
  "description": "Scrape metadata from any URL using Open Graph, JSON-LD, HTML meta tags, and smart fallbacks.",
4
4
  "homepage": "https://metascraper.js.org",
5
- "version": "5.58.5",
5
+ "version": "5.58.7",
6
6
  "types": "src/index.d.ts",
7
7
  "main": "src/index.js",
8
8
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "unfurl"
28
28
  ],
29
29
  "dependencies": {
30
- "@metascraper/helpers": "5.58.4",
30
+ "@metascraper/helpers": "5.58.7",
31
31
  "cheerio": "~1.2.0",
32
32
  "debug-logfmt": "~1.4.15",
33
33
  "whoops": "~5.1.4"
@@ -55,5 +55,5 @@
55
55
  "tsd": {
56
56
  "directory": "test/types"
57
57
  },
58
- "gitHead": "82d52338c5c37875c19986310966698808c6aad9"
58
+ "gitHead": "55327bdb0d00ce621f3a654b35e5010aabc1eb2e"
59
59
  }
package/src/get-data.js CHANGED
@@ -3,6 +3,11 @@
3
3
  const debug = require('debug-logfmt')('metascraper:get-data')
4
4
  const { findRule, has } = require('@metascraper/helpers')
5
5
 
6
+ const PRINTABLE_TYPES = new Set(['string', 'number', 'boolean', 'bigint'])
7
+
8
+ const formatValue = value =>
9
+ value === null || PRINTABLE_TYPES.has(typeof value) ? value : typeof value
10
+
6
11
  const getData = async ({ rules, ...props }) => {
7
12
  const data = {}
8
13
 
@@ -26,7 +31,9 @@ const getData = async ({ rules, ...props }) => {
26
31
  }
27
32
 
28
33
  duration(
29
- `${propName}=${normalizedValue} rules=${innerRules.length} status=${status}`
34
+ `${propName}=${formatValue(normalizedValue)} rules=${
35
+ innerRules.length
36
+ } status=${status}`
30
37
  )
31
38
  data[propName] = normalizedValue
32
39
  })