Default when there is no applicationServerKey meta on the page

This commit is contained in:
Morgan Bazalgette 2018-03-31 19:12:24 +02:00 committed by Haelwenn (lanodan) Monnier
parent a915aca1db
commit 882d44afdf
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
2 changed files with 8 additions and 2 deletions

View file

@ -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;

View file

@ -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;