add error handling for invalid URLs

This commit is contained in:
Marcus Jaschen 2023-12-21 13:21:15 +01:00 committed by Gautier P
parent 2a7dc36678
commit c7e1c4e6a7

View file

@ -48,7 +48,11 @@ BR.ShareRoute = L.Class.extend({
} }
if (BR.Util.localStorageAvailable()) { if (BR.Util.localStorageAvailable()) {
localStorage.setItem('share/mastodonInstance', new URL(mastodonServer).hostname); try {
localStorage.setItem('share/mastodonInstance', new URL(mastodonServer).hostname);
} catch (exception) {
console.error('Cannot store Mastodon instance', exception);
}
} }
window.open(mastodonServer + '/share?text=' + encodeURIComponent(self.getShareUrl()), '_blank'); window.open(mastodonServer + '/share?text=' + encodeURIComponent(self.getShareUrl()), '_blank');