Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
check that notifTitle is a string when provided to launchNativeNotifi…
Browse files Browse the repository at this point in the history
…cation
  • Loading branch information
rmisio committed Oct 25, 2017
1 parent 931205a commit bcb274b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/utils/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ export function launchNativeNotification(notifTitle = '', options = {}) {
'as a string.');
}

if (typeof notifTitle !== 'string') {
throw new Error('Please provide the notifTitle as a string.');
}

const notifOptions = {
silent: true,
...(_.omit(options || {}, 'onclick', 'onerror')),
body: options.body ? stripHtml(options.body) : '',
};

const title = typeof notifTitle === 'string' ? stripHtml(notifTitle) : notifTitle;
const notif = new Notification(title, notifOptions);
const notif = new Notification(notifTitle, notifOptions);

if (typeof options.onclick === 'function') {
notif.addEventListener('click', notifOptions.onclick);
Expand Down

0 comments on commit bcb274b

Please sign in to comment.