diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index f4f4087..ae1a21e 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -44,9 +44,17 @@ async function resolvePlatform(url) { const urlObj = new URL(url); if (domainCache.has(urlObj.hostname)) return domainCache.get(urlObj.hostname); - const probe = await fetch(urlObj.origin + "/.well-known/nodeinfo", { + const res = await fetch(urlObj.origin + "/.well-known/nodeinfo", { headers: {"User-Agent": FRIENDLY_USERAGENT}, - }).then((res) => res.json()); + }).then((res) => res.text()); + + if (!res.startsWith("{")) { + logger.error("fedimbed", `No nodeinfo for "${urlObj.hostname}"???`); + domainCache.set(urlObj.hostname, null); + return null; + } + + const probe = JSON.parse(res); if (!probe?.links) { logger.error("fedimbed", `No nodeinfo for "${urlObj.hostname}"???`); @@ -123,7 +131,7 @@ async function processUrl(msg, url, spoiler = false) { url = urlObj.href; } - let platform = await resolvePlatform(url); + let platform = await resolvePlatform(url) ?? ""; let color = PLATFORM_COLORS[platform]; let platformName = platform .replace("gotosocial", "GoToSocial")