metascraper-x 5.45.9 → 5.45.15
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/README.md +1 -7
- package/package.json +3 -3
- package/src/index.js +2 -17
package/README.md
CHANGED
|
@@ -20,12 +20,6 @@ $ npm install metascraper-x --save
|
|
|
20
20
|
|
|
21
21
|
#### options
|
|
22
22
|
|
|
23
|
-
##### gotOpts
|
|
24
|
-
|
|
25
|
-
Type: `object`
|
|
26
|
-
|
|
27
|
-
Any option provided here will passed to [got#options](https://github.com/sindresorhus/got#options).
|
|
28
|
-
|
|
29
23
|
##### resolveUrls
|
|
30
24
|
|
|
31
25
|
Type: `boolean`
|
|
@@ -36,7 +30,7 @@ Set to `true` if you want to resolve `t.co` URLs into the final URL.
|
|
|
36
30
|
|
|
37
31
|
Type: `function`
|
|
38
32
|
|
|
39
|
-
|
|
33
|
+
The function implementation that resolves `t.co` into a the final URL.
|
|
40
34
|
|
|
41
35
|
## License
|
|
42
36
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "metascraper-x",
|
|
3
3
|
"description": "Metascraper integration with x.com",
|
|
4
4
|
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-x",
|
|
5
|
-
"version": "5.45.
|
|
5
|
+
"version": "5.45.15",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"author": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"spotify"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@metascraper/helpers": "^5.45.
|
|
27
|
+
"@metascraper/helpers": "^5.45.10"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"ava": "5"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"test": "NODE_PATH=.. TZ=UTC ava --timeout 15s"
|
|
40
40
|
},
|
|
41
41
|
"license": "MIT",
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "85d36219ec9c58e464ff51721d87a93e932fb4eb"
|
|
43
43
|
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const reachableUrl = require('reachable-url')
|
|
4
3
|
const {
|
|
5
4
|
getUrls,
|
|
6
5
|
author,
|
|
@@ -23,11 +22,7 @@ const test = memoizeOne(url =>
|
|
|
23
22
|
['twitter.com', 'x.com'].includes(parseUrl(url).domain)
|
|
24
23
|
)
|
|
25
24
|
|
|
26
|
-
module.exports = ({
|
|
27
|
-
gotOpts,
|
|
28
|
-
resolveUrls = false,
|
|
29
|
-
resolveUrl = url => url
|
|
30
|
-
} = {}) => {
|
|
25
|
+
module.exports = ({ resolveUrls = false, resolveUrl = url => url } = {}) => {
|
|
31
26
|
const rules = {
|
|
32
27
|
author: [
|
|
33
28
|
toAuthor($ => {
|
|
@@ -45,18 +40,8 @@ module.exports = ({
|
|
|
45
40
|
toDescription(async $ => {
|
|
46
41
|
let description = $('meta[property="og:description"]').attr('content')
|
|
47
42
|
if (!resolveUrls) return description
|
|
48
|
-
|
|
49
43
|
const urls = getUrls(description)
|
|
50
|
-
|
|
51
|
-
const resolvedUrls = await Promise.all(
|
|
52
|
-
urls.map(async url => {
|
|
53
|
-
const response = await reachableUrl(url, gotOpts)
|
|
54
|
-
if (reachableUrl.isReachable(response)) {
|
|
55
|
-
return resolveUrl(response.url)
|
|
56
|
-
}
|
|
57
|
-
return url
|
|
58
|
-
})
|
|
59
|
-
)
|
|
44
|
+
const resolvedUrls = await Promise.all(urls.map(resolveUrl))
|
|
60
45
|
|
|
61
46
|
for (const [index, url] of resolvedUrls.entries()) {
|
|
62
47
|
const original = urls[index]
|