@metascraper/helpers 5.45.0 → 5.45.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.
- package/index.js +14 -5
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -19,12 +19,18 @@ const isUri = require('is-uri')
|
|
|
19
19
|
const { URL } = require('url')
|
|
20
20
|
const tldts = require('tldts')
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const METASCRAPER_RE2 = process.env.METASCRAPER_RE2
|
|
23
|
+
? process.env.METASCRAPER_RE2 === 'true'
|
|
24
|
+
: undefined
|
|
25
|
+
|
|
26
|
+
const urlRegexForTest = require('url-regex-safe')({
|
|
23
27
|
exact: true,
|
|
24
28
|
parens: true,
|
|
25
|
-
re2:
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
re2: METASCRAPER_RE2
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const urlRegexForMatch = require('url-regex-safe')({
|
|
33
|
+
re2: METASCRAPER_RE2
|
|
28
34
|
})
|
|
29
35
|
|
|
30
36
|
const {
|
|
@@ -120,7 +126,7 @@ const AUTHOR_MAX_LENGTH = 128
|
|
|
120
126
|
const removeLocation = value => replace(value, REGEX_LOCATION, '')
|
|
121
127
|
|
|
122
128
|
const isUrl = (url, { relative = false } = {}) =>
|
|
123
|
-
relative ? isRelativeUrl(url) :
|
|
129
|
+
relative ? isRelativeUrl(url) : urlRegexForTest.test(url)
|
|
124
130
|
|
|
125
131
|
const urlObject = (...args) => {
|
|
126
132
|
try {
|
|
@@ -485,6 +491,8 @@ const loadIframe = (url, $, { timeout = 5000 } = {}) =>
|
|
|
485
491
|
listen(iframe, 'add', load)
|
|
486
492
|
})
|
|
487
493
|
|
|
494
|
+
const getUrls = input => String(input).match(urlRegexForMatch) ?? []
|
|
495
|
+
|
|
488
496
|
module.exports = {
|
|
489
497
|
$filter,
|
|
490
498
|
$jsonld,
|
|
@@ -499,6 +507,7 @@ module.exports = {
|
|
|
499
507
|
extension,
|
|
500
508
|
fileExtension,
|
|
501
509
|
findRule,
|
|
510
|
+
getUrls,
|
|
502
511
|
has,
|
|
503
512
|
image,
|
|
504
513
|
imageExtensions,
|
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.45.
|
|
5
|
+
"version": "5.45.7",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"audio-extensions": "0.0.0",
|
|
26
26
|
"chrono-node": "~2.7.5",
|
|
27
27
|
"condense-whitespace": "~2.0.0",
|
|
28
|
-
"data-uri-utils": "~1.0.
|
|
28
|
+
"data-uri-utils": "~1.0.8",
|
|
29
29
|
"entities": "~4.5.0",
|
|
30
30
|
"file-extension": "~4.0.5",
|
|
31
31
|
"has-values": "~2.0.1",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"microsoft-capitalize": "~1.0.5",
|
|
41
41
|
"mime": "~3.0.0",
|
|
42
42
|
"normalize-url": "~6.1.0",
|
|
43
|
-
"re2": "~1.20.
|
|
43
|
+
"re2": "~1.20.11",
|
|
44
44
|
"smartquotes": "~2.3.2",
|
|
45
|
-
"tldts": "~6.1.
|
|
45
|
+
"tldts": "~6.1.20",
|
|
46
46
|
"url-regex-safe": "~4.0.0",
|
|
47
47
|
"video-extensions": "~1.2.0"
|
|
48
48
|
},
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "86ed64c8ef626bf651fa58618bb5dfa08d5a9f5a"
|
|
67
67
|
}
|