From c7e1c4e6a733c0f2c7d4b97311acaf64d67168e8 Mon Sep 17 00:00:00 2001 From: Marcus Jaschen Date: Thu, 21 Dec 2023 13:21:15 +0100 Subject: [PATCH] add error handling for invalid URLs --- js/control/ShareRoute.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/control/ShareRoute.js b/js/control/ShareRoute.js index ad017b1..dca79fc 100644 --- a/js/control/ShareRoute.js +++ b/js/control/ShareRoute.js @@ -48,7 +48,11 @@ BR.ShareRoute = L.Class.extend({ } 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');