@unavatar/core 3.21.0 → 3.23.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/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.
|
|
5
|
+
"version": "3.23.0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const getAvatarUrl = input => {
|
|
4
|
+
const [first, second] = input.split(':')
|
|
5
|
+
const type = second ? first : 'app'
|
|
6
|
+
const id = encodeURIComponent(second ?? first)
|
|
7
|
+
|
|
8
|
+
switch (type) {
|
|
9
|
+
case 'app':
|
|
10
|
+
return `https://play.google.com/store/apps/details?id=${id}`
|
|
11
|
+
case 'dev':
|
|
12
|
+
return `https://play.google.com/store/apps/dev?id=${id}`
|
|
13
|
+
default:
|
|
14
|
+
throw new Error(`Unsupported Google Play type: ${type}`)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = ({ createHtmlProvider, getOgImage }) =>
|
|
19
|
+
createHtmlProvider({
|
|
20
|
+
name: 'google-play',
|
|
21
|
+
url: getAvatarUrl,
|
|
22
|
+
getter: getOgImage
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
module.exports.getAvatarUrl = getAvatarUrl
|
package/src/providers/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const providersBy = {
|
|
|
14
14
|
'flickr',
|
|
15
15
|
'github',
|
|
16
16
|
'gitlab',
|
|
17
|
+
'google-play',
|
|
17
18
|
'instagram',
|
|
18
19
|
'ko-fi',
|
|
19
20
|
'linkedin',
|
|
@@ -29,6 +30,7 @@ const providersBy = {
|
|
|
29
30
|
'snapchat',
|
|
30
31
|
'soundcloud',
|
|
31
32
|
'spotify',
|
|
33
|
+
'stackoverflow',
|
|
32
34
|
'steam',
|
|
33
35
|
'substack',
|
|
34
36
|
'telegram',
|
|
@@ -59,6 +61,7 @@ module.exports = ctx => {
|
|
|
59
61
|
github: require('./github')(ctx),
|
|
60
62
|
gitlab: require('./gitlab')(ctx),
|
|
61
63
|
google: require('./google')(ctx),
|
|
64
|
+
'google-play': require('./google-play')(ctx),
|
|
62
65
|
gravatar: require('./gravatar')(ctx),
|
|
63
66
|
instagram: require('./instagram')(ctx),
|
|
64
67
|
'ko-fi': require('./ko-fi')(ctx),
|
|
@@ -76,6 +79,7 @@ module.exports = ctx => {
|
|
|
76
79
|
snapchat: require('./snapchat')(ctx),
|
|
77
80
|
soundcloud: require('./soundcloud')(ctx),
|
|
78
81
|
spotify: require('./spotify')(ctx),
|
|
82
|
+
stackoverflow: require('./stackoverflow')(ctx),
|
|
79
83
|
steam: require('./steam')(ctx),
|
|
80
84
|
substack: require('./substack')(ctx),
|
|
81
85
|
telegram: require('./telegram')(ctx),
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const AVATAR_SELECTOR = '.js-usermini-avatar-container img'
|
|
4
|
+
|
|
5
|
+
const normalizeInput = input => {
|
|
6
|
+
let normalizedInput = input.replace(/^\/+/, '')
|
|
7
|
+
if (normalizedInput.startsWith('users/')) {
|
|
8
|
+
normalizedInput = normalizedInput.slice('users/'.length)
|
|
9
|
+
}
|
|
10
|
+
return normalizedInput
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const getProfileUrl = input =>
|
|
14
|
+
`https://stackoverflow.com/users/${normalizeInput(input)}`
|
|
15
|
+
|
|
16
|
+
const getAvatarUrl = $ =>
|
|
17
|
+
$(`${AVATAR_SELECTOR}[width="128"]`).attr('src') ||
|
|
18
|
+
$(AVATAR_SELECTOR).first().attr('src')
|
|
19
|
+
|
|
20
|
+
module.exports = ({ createHtmlProvider }) =>
|
|
21
|
+
createHtmlProvider({
|
|
22
|
+
name: 'stackoverflow',
|
|
23
|
+
url: getProfileUrl,
|
|
24
|
+
getter: getAvatarUrl
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
module.exports.getProfileUrl = getProfileUrl
|
|
28
|
+
module.exports.getAvatarUrl = getAvatarUrl
|