Skip to content

Commit

Permalink
fix: Handle unknown software names correctly when sharing on Fediverse
Browse files Browse the repository at this point in the history
Node info download could result in something like "peertube" that we don't have an endpoint for. Rather than silently producing a JavaScript error, the page should assume a Mastodon-compatible API.
  • Loading branch information
palant committed Oct 19, 2023
1 parent 46be86d commit eb1b7b0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions assets/js/fedishare.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ document.addEventListener("DOMContentLoaded", () => {

getSoftwareName(instance).then(name => {
let projects = JSON.parse(document.body.getAttribute("data-projects"));
let endpoint = projects[name];
let endpoint = projects.hasOwnProperty(name) ? projects[name] : projects.mastodon;
endpoint = endpoint.replace("{title}", encodeURIComponent(title));
endpoint = endpoint.replace("{description}", encodeURIComponent(description));
endpoint = endpoint.replace("{url}", encodeURIComponent(url));
endpoint = endpoint.replace("{text}", encodeURIComponent(text));
if (projects.hasOwnProperty(name))
location.href = `https://${instance}/${endpoint}`;
location.href = `https://${instance}/${endpoint}`;
});
});

Expand Down

0 comments on commit eb1b7b0

Please sign in to comment.