From 882d44afdffe1b2edfa6aed7562b0259a737a62a Mon Sep 17 00:00:00 2001 From: Morgan Bazalgette Date: Sat, 31 Mar 2018 19:12:24 +0200 Subject: [PATCH] Default when there is no applicationServerKey meta on the page --- .../flavours/glitch/actions/push_notifications/registerer.js | 5 ++++- .../mastodon/actions/push_notifications/registerer.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/push_notifications/registerer.js b/app/javascript/flavours/glitch/actions/push_notifications/registerer.js index 8fdb239f7..45ca25cde 100644 --- a/app/javascript/flavours/glitch/actions/push_notifications/registerer.js +++ b/app/javascript/flavours/glitch/actions/push_notifications/registerer.js @@ -18,7 +18,10 @@ const urlBase64ToUint8Array = (base64String) => { return outputArray; }; -const getApplicationServerKey = () => document.querySelector('[name="applicationServerKey"]').getAttribute('content'); +const getApplicationServerKey = () => { + const k = document.querySelector('[name="applicationServerKey"]'); + return k === null ? '' : k.getAttribute('content'); +}; const getRegistration = () => navigator.serviceWorker.ready; diff --git a/app/javascript/mastodon/actions/push_notifications/registerer.js b/app/javascript/mastodon/actions/push_notifications/registerer.js index b0f42b6a2..67bf7cb4e 100644 --- a/app/javascript/mastodon/actions/push_notifications/registerer.js +++ b/app/javascript/mastodon/actions/push_notifications/registerer.js @@ -14,7 +14,10 @@ const urlBase64ToUint8Array = (base64String) => { return decodeBase64(base64); }; -const getApplicationServerKey = () => document.querySelector('[name="applicationServerKey"]').getAttribute('content'); +const getApplicationServerKey = () => { + const k = document.querySelector('[name="applicationServerKey"]'); + return k === null ? '' : k.getAttribute('content'); +}; const getRegistration = () => navigator.serviceWorker.ready;