@unavatar/core 3.32.4 → 3.32.6
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 +2 -2
- package/src/providers/dockerhub.js +14 -2
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.32.
|
|
5
|
+
"version": "3.32.6",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
},
|
|
207
207
|
"nano-staged": {
|
|
208
208
|
"*.js": [
|
|
209
|
-
"npx
|
|
209
|
+
"npx @kikobeats/prettier-standard",
|
|
210
210
|
"standard --fix"
|
|
211
211
|
],
|
|
212
212
|
"package.json": [
|
|
@@ -3,8 +3,17 @@
|
|
|
3
3
|
const API_URL = 'https://hub.docker.com/v2/users'
|
|
4
4
|
|
|
5
5
|
const getAvatarUrl = input => `${API_URL}/${encodeURIComponent(input)}/`
|
|
6
|
+
const getMaxResGravatarUrl = ({ constants, input }) => {
|
|
7
|
+
const url = new URL(input)
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
// `d=404` makes missing avatars fail instead of falling back to placeholders.
|
|
10
|
+
url.searchParams.set('s', String(constants.AVATAR_SIZE))
|
|
11
|
+
url.searchParams.set('d', '404')
|
|
12
|
+
|
|
13
|
+
return url.toString()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = ({ constants, got }) =>
|
|
8
17
|
async function dockerhub (input) {
|
|
9
18
|
const { body, statusCode } = await got(getAvatarUrl(input), {
|
|
10
19
|
responseType: 'json',
|
|
@@ -13,7 +22,10 @@ module.exports = ({ got }) =>
|
|
|
13
22
|
|
|
14
23
|
if (statusCode >= 400) return
|
|
15
24
|
|
|
16
|
-
|
|
25
|
+
if (!body?.gravatar_url) return undefined
|
|
26
|
+
|
|
27
|
+
return getMaxResGravatarUrl({ constants, input: body.gravatar_url })
|
|
17
28
|
}
|
|
18
29
|
|
|
19
30
|
module.exports.getAvatarUrl = getAvatarUrl
|
|
31
|
+
module.exports.getMaxResGravatarUrl = getMaxResGravatarUrl
|