@metascraper/helpers 5.35.1 → 5.36.0
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/index.js +13 -1
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const memoizeOne = require('memoize-one').default || require('memoize-one')
|
|
4
|
-
const urlRegex = require('url-regex-safe')({ exact: true, parens: true })
|
|
5
4
|
const condenseWhitespace = require('condense-whitespace')
|
|
6
5
|
const { getExtension: mimeExtension } = require('mime')
|
|
7
6
|
const capitalize = require('microsoft-capitalize')
|
|
@@ -19,6 +18,14 @@ const isUri = require('is-uri')
|
|
|
19
18
|
const { URL } = require('url')
|
|
20
19
|
const tldts = require('tldts')
|
|
21
20
|
|
|
21
|
+
const urlRegex = require('url-regex-safe')({
|
|
22
|
+
exact: true,
|
|
23
|
+
parens: true,
|
|
24
|
+
re2: process.env.METASCRAPER_RE2
|
|
25
|
+
? process.env.METASCRAPER_RE2 === 'true'
|
|
26
|
+
: undefined
|
|
27
|
+
})
|
|
28
|
+
|
|
22
29
|
const {
|
|
23
30
|
chain,
|
|
24
31
|
eq,
|
|
@@ -163,6 +170,10 @@ const titleize = (src, opts = {}) => {
|
|
|
163
170
|
return title
|
|
164
171
|
}
|
|
165
172
|
|
|
173
|
+
const $twitter = ($, selector) =>
|
|
174
|
+
$(`meta[name="${selector}"]`).attr('content') ||
|
|
175
|
+
$(`meta[property="${selector}"]`).attr('content')
|
|
176
|
+
|
|
166
177
|
const $filter = ($, matchedEl, fn = $filter.fn) => {
|
|
167
178
|
let matched
|
|
168
179
|
|
|
@@ -466,6 +477,7 @@ const loadIframe = (url, $, { timeout = 5000 } = {}) =>
|
|
|
466
477
|
module.exports = {
|
|
467
478
|
$filter,
|
|
468
479
|
$jsonld,
|
|
480
|
+
$twitter,
|
|
469
481
|
absoluteUrl,
|
|
470
482
|
audio,
|
|
471
483
|
audioExtensions,
|
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://nicedoc.io/microlinkhq/metascraper/packages/metascraper-helpers",
|
|
5
|
-
"version": "5.
|
|
5
|
+
"version": "5.36.0",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"re2": "~1.20.1",
|
|
43
43
|
"smartquotes": "~2.3.2",
|
|
44
44
|
"tldts": "~6.0.12",
|
|
45
|
-
"url-regex-safe": "~
|
|
45
|
+
"url-regex-safe": "~4.0.0",
|
|
46
46
|
"video-extensions": "~1.2.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "c10dbbb9e98c16b72d34dcea301c7fecd71d760f"
|
|
66
66
|
}
|