@unavatar/core 3.71.7 → 3.71.8
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 +1 -1
- package/src/providers/codeforces.js +10 -1
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.71.
|
|
5
|
+
"version": "3.71.8",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
@@ -6,13 +6,22 @@ const HANDLES_SEPARATOR = ';'
|
|
|
6
6
|
|
|
7
7
|
const DEFAULT_PHOTO_RE = /\/no-(title|avatar)\.jpg$/
|
|
8
8
|
|
|
9
|
+
const USERPIC_ORIGIN = 'https://userpic.codeforces.org/'
|
|
10
|
+
|
|
11
|
+
const USERPIC_MIRROR = 'https://codeforces.com/userpic.codeforces.org/'
|
|
12
|
+
|
|
13
|
+
const toUserpicMirror = url =>
|
|
14
|
+
url.startsWith(USERPIC_ORIGIN)
|
|
15
|
+
? USERPIC_MIRROR + url.slice(USERPIC_ORIGIN.length)
|
|
16
|
+
: url
|
|
17
|
+
|
|
9
18
|
const getAvatarUrl = input => `${API_URL}?handles=${encodeURIComponent(input)}`
|
|
10
19
|
|
|
11
20
|
const getAvatar = body => {
|
|
12
21
|
const pic = body?.result?.[0]?.titlePhoto
|
|
13
22
|
if (typeof pic !== 'string' || !pic) return undefined
|
|
14
23
|
if (DEFAULT_PHOTO_RE.test(pic)) return undefined
|
|
15
|
-
return pic
|
|
24
|
+
return toUserpicMirror(pic)
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
module.exports = ({ got }) =>
|