@unavatar/core 3.7.48 → 3.7.49
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/package.json +6 -4
- package/src/avatar/auto.js +13 -5
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@unavatar/core",
|
|
3
3
|
"description": "Get unified user avatar from social networks, including Instagram, SoundCloud, Telegram, Twitter, YouTube & more.",
|
|
4
4
|
"homepage": "https://unavatar.io",
|
|
5
|
-
"version": "3.7.
|
|
5
|
+
"version": "3.7.49",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"youtube"
|
|
108
108
|
],
|
|
109
109
|
"dependencies": {
|
|
110
|
-
"@keyvhq/compress": "~2.
|
|
110
|
+
"@keyvhq/compress": "~2.2.0",
|
|
111
111
|
"@keyvhq/core": "~2.1.15",
|
|
112
112
|
"@keyvhq/memoize": "~2.1.16",
|
|
113
113
|
"@keyvhq/multi": "~2.1.15",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"@metascraper/helpers": "~5.49.24",
|
|
116
116
|
"@microlink/mql": "~0.14.2",
|
|
117
117
|
"@microlink/ping-url": "~1.4.16",
|
|
118
|
-
"browserless": "~10.
|
|
118
|
+
"browserless": "~10.12.0",
|
|
119
119
|
"cacheable-lookup": "~6.1.0",
|
|
120
120
|
"data-uri-regex": "~0.1.4",
|
|
121
121
|
"debug-logfmt": "~1.4.7",
|
|
@@ -130,13 +130,15 @@
|
|
|
130
130
|
"p-cancelable": "2.1.1",
|
|
131
131
|
"p-timeout": "~4.1.0",
|
|
132
132
|
"puppeteer": "~24.37.5",
|
|
133
|
+
"re2": "~1.23.3",
|
|
133
134
|
"srcset": "~4.0.0",
|
|
135
|
+
"stable-regex": "~1.0.0",
|
|
134
136
|
"tangerine": "~2.0.2",
|
|
135
137
|
"top-crawler-agents": "~1.0.34",
|
|
136
138
|
"top-user-agents": "~2.1.95",
|
|
137
139
|
"ua-hints": "~1.0.1",
|
|
138
140
|
"unique-random-array": "~2.0.0",
|
|
139
|
-
"url-regex": "~
|
|
141
|
+
"url-regex-safe": "~4.0.0"
|
|
140
142
|
},
|
|
141
143
|
"devDependencies": {
|
|
142
144
|
"@commitlint/cli": "latest",
|
package/src/avatar/auto.js
CHANGED
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
const isAbsoluteUrl = require('is-absolute-url')
|
|
4
4
|
const dataUriRegex = require('data-uri-regex')
|
|
5
|
+
const stableRegex = require('stable-regex')
|
|
6
|
+
const urlRegex = require('url-regex-safe')
|
|
5
7
|
const isEmail = require('is-email-like')
|
|
6
8
|
const pTimeout = require('p-timeout')
|
|
7
|
-
const urlRegex = require('url-regex')
|
|
8
9
|
const pAny = require('p-any')
|
|
9
10
|
|
|
10
11
|
const httpStatus = require('../util/http-status')
|
|
11
12
|
const isIterable = require('../util/is-iterable')
|
|
12
13
|
const ExtendableError = require('../util/error')
|
|
13
14
|
|
|
15
|
+
const DATA_URI_REGEX = dataUriRegex()
|
|
16
|
+
const DOMAIN_REGEX = urlRegex({ strict: false })
|
|
17
|
+
|
|
14
18
|
const getInputType = input => {
|
|
15
19
|
if (isEmail(input)) return 'email'
|
|
16
|
-
if (
|
|
20
|
+
if (stableRegex(DOMAIN_REGEX, input)) return 'domain'
|
|
17
21
|
return 'username'
|
|
18
22
|
}
|
|
19
23
|
|
|
@@ -22,12 +26,16 @@ const factory = ({ constants, providers, providersBy, reachableUrl }) => {
|
|
|
22
26
|
|
|
23
27
|
const getAvatarContent = provider => async output => {
|
|
24
28
|
if (typeof output !== 'string' || output === '') {
|
|
25
|
-
const message =
|
|
26
|
-
|
|
29
|
+
const message =
|
|
30
|
+
output === undefined ? 'not found' : `\`${output}\` is invalid`
|
|
31
|
+
const statusCode =
|
|
32
|
+
output === undefined
|
|
33
|
+
? httpStatus.NOT_FOUND
|
|
34
|
+
: httpStatus.UNPROCESSABLE_ENTITY
|
|
27
35
|
throw new ExtendableError({ provider, message, statusCode })
|
|
28
36
|
}
|
|
29
37
|
|
|
30
|
-
if (
|
|
38
|
+
if (stableRegex(DATA_URI_REGEX, output)) {
|
|
31
39
|
return { type: 'buffer', data: output }
|
|
32
40
|
}
|
|
33
41
|
|