@unavatar/core 3.46.3 → 3.46.4

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.46.3",
5
+ "version": "3.46.4",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
@@ -127,7 +127,7 @@
127
127
  "@keyvhq/redis": "~2.2.3",
128
128
  "@metascraper/helpers": "~5.53.0",
129
129
  "@microlink/mql": "~0.17.0",
130
- "@microlink/ping-url": "~1.4.16",
130
+ "@microlink/ping-url": "~1.5.0",
131
131
  "bimi-url": "~1.0.0",
132
132
  "browserless": "~13.6.0",
133
133
  "cacheable-lookup": "~6.1.0",
@@ -2,6 +2,8 @@
2
2
 
3
3
  const createPingUrl = require('@microlink/ping-url')
4
4
 
5
+ const isRedirectStatus = statusCode => statusCode >= 300 && statusCode < 400
6
+
5
7
  module.exports = ({ got, pingCache }) => {
6
8
  const pingUrl = createPingUrl(pingCache, {
7
9
  value: ({ url, statusCode }) => ({ url, statusCode })
@@ -11,7 +13,17 @@ module.exports = ({ got, pingCache }) => {
11
13
  const context = {}
12
14
  const response = await pingUrl(url, { ...got.gotOpts, ...opts, context })
13
15
  const { reservedAddress } = context
14
- return reservedAddress ? { ...response, reservedAddress } : response
16
+
17
+ // reachable-url leaves the redirect hop as the status when a beforeRedirect
18
+ // hook aborts, and the ping cache only memoizes {url, statusCode} — so a
19
+ // later hit would replay that hop without the reserved-address refusal.
20
+ const statusCode = isRedirectStatus(response.statusCode)
21
+ ? 404
22
+ : response.statusCode
23
+
24
+ if (reservedAddress) return { ...response, statusCode, reservedAddress }
25
+ if (statusCode === response.statusCode) return response
26
+ return { ...response, statusCode }
15
27
  }
16
28
 
17
29
  reachableUrl.isReachable = createPingUrl.isReachable