@unavatar/core 3.45.22 → 3.45.24

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 CHANGED
@@ -98,7 +98,7 @@
98
98
 
99
99
  ---
100
100
 
101
- Last updated on June 14, 2026
101
+ Last updated on June 19, 2026
102
102
 
103
103
  ![logo](https://unavatar.io/api/og ":id=banner")
104
104
 
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.45.22",
5
+ "version": "3.45.24",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
package/src/index.js CHANGED
@@ -48,6 +48,7 @@ module.exports = ({
48
48
  getOgImage,
49
49
  NOT_FOUND,
50
50
  got,
51
+ reachableUrl,
51
52
  isReservedIp,
52
53
  githubSearchCache: cache.githubSearchCache,
53
54
  itunesSearchCache: cache.itunesSearchCache
@@ -1,6 +1,36 @@
1
1
  'use strict'
2
2
 
3
- module.exports = () =>
4
- function duckduckgo (input) {
5
- return `https://icons.duckduckgo.com/ip3/${input}.ico`
3
+ const getAvatarUrl = host => `https://icons.duckduckgo.com/ip3/${host}.ico`
4
+
5
+ // DuckDuckGo's icon service is keyed by exact hostname and normalizes
6
+ // www <-> apex only for popular domains. Smaller sites are indexed under the
7
+ // single host their crawler saw (usually the canonical `www.` redirect target),
8
+ // so the other variant 404s. Toggle the prefix to recover it.
9
+ const toggleWww = host =>
10
+ host.startsWith('www.') ? host.slice(4) : `www.${host}`
11
+
12
+ module.exports = ({ reachableUrl }) => {
13
+ const isReachable = async url => {
14
+ try {
15
+ const { statusCode } = await reachableUrl(url)
16
+ return reachableUrl.isReachable({ statusCode })
17
+ } catch {
18
+ return false
19
+ }
6
20
  }
21
+
22
+ return async function duckduckgo (input) {
23
+ const primary = getAvatarUrl(input)
24
+ if (await isReachable(primary)) return primary
25
+
26
+ const alternate = getAvatarUrl(toggleWww(input))
27
+ if (alternate !== primary && (await isReachable(alternate))) {
28
+ return alternate
29
+ }
30
+
31
+ return primary
32
+ }
33
+ }
34
+
35
+ module.exports.getAvatarUrl = getAvatarUrl
36
+ module.exports.toggleWww = toggleWww