fix: avoid using potentially missing URL

This commit is contained in:
Yarmo Mackenbach 2023-09-19 13:35:11 +02:00
parent cae1020f45
commit 81d5ba0d57
No known key found for this signature in database
GPG key ID: 3C57D093219103A3

View file

@ -82,12 +82,12 @@ export const functions = {
case 'Note': { case 'Note': {
claimData.profile.uri = proofData.result.attributedTo claimData.profile.uri = proofData.result.attributedTo
const personData = await fetcher.activitypub.fn({ url: proofData.result.attributedTo }, opts) const personData = await fetcher.activitypub.fn({ url: proofData.result.attributedTo }, opts)
claimData.profile.display = `@${personData.preferredUsername}@${new URL(proofData.result.url).hostname}` claimData.profile.display = `@${personData.preferredUsername}@${new URL(claimData.proof.request.uri).hostname}`
break break
} }
case 'Person': case 'Person':
claimData.profile.display = `@${proofData.result.preferredUsername}@${new URL(proofData.result.url).hostname}` claimData.profile.display = `@${proofData.result.preferredUsername}@${new URL(claimData.proof.request.uri).hostname}`
break break
default: default:
@ -95,7 +95,7 @@ export const functions = {
} }
// Attempt to fetch and process the instance's NodeInfo data // Attempt to fetch and process the instance's NodeInfo data
const nodeinfo = await _processNodeinfo(new URL(proofData.result.url).hostname) const nodeinfo = await _processNodeinfo(new URL(claimData.proof.request.uri).hostname)
if (nodeinfo) { if (nodeinfo) {
claimData.about.name = nodeinfo.software.name claimData.about.name = nodeinfo.software.name
claimData.about.id = nodeinfo.software.name claimData.about.id = nodeinfo.software.name