Skip to content

Commit

Permalink
feat: When downloading nodeinfo for “Share to Fediverse”, support 2.1…
Browse files Browse the repository at this point in the history
… schema
  • Loading branch information
palant committed Jan 11, 2025
1 parent 01265d8 commit 6573fae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion assets/js/fedishare.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ function getSoftwareName(instance) {
if (option.value == instance)
return Promise.resolve(option.getAttribute("data-project"));

const SUPPORTED_SCHEMAS = [
"http://nodeinfo.diaspora.software/ns/schema/2.0",
"http://nodeinfo.diaspora.software/ns/schema/2.1",
];
return fetch(`https://${instance}/.well-known/nodeinfo`).then(response => response.json()).then(response => {
if (response && Array.isArray(response.links))
for (let link of response.links)
if (link.rel == "http://nodeinfo.diaspora.software/ns/schema/2.0" && typeof link.href == "string")
if (SUPPORTED_SCHEMAS.includes(link.rel) && typeof link.href == "string")
return fetch(link.href);
throw new Exception(".well-known/nodeinfo file does not contain a nodeinfo link");
}).then(response => response.json()).then(response => {
Expand Down

0 comments on commit 6573fae

Please sign in to comment.