2018-04-16 19:08:04 +02:00
|
|
|
/**
|
|
|
|
* Indicates whether the user is viewing the app through an extension like window or through a notification.
|
|
|
|
* Used to make some style decisions on the frontend, and when deciding whether to close the popup in the backend.
|
|
|
|
*
|
|
|
|
* @returns {string} Returns 'popup' if the user is viewing through the browser ('home.html') or popup extension
|
|
|
|
* ('popup.html'). Otherwise it returns 'notification'.
|
|
|
|
*
|
|
|
|
*/
|
2016-11-11 19:26:12 +01:00
|
|
|
module.exports = function isPopupOrNotification () {
|
2016-08-17 01:46:44 +02:00
|
|
|
const url = window.location.href
|
2018-04-16 19:08:04 +02:00
|
|
|
|
2017-11-29 05:24:35 +01:00
|
|
|
if (url.match(/popup.html(?:\?.+)*$/) ||
|
|
|
|
url.match(/home.html(?:\?.+)*$/) || url.match(/home.html(?:#.*)*$/)) {
|
2016-08-17 01:46:44 +02:00
|
|
|
return 'popup'
|
|
|
|
} else {
|
|
|
|
return 'notification'
|
|
|
|
}
|
|
|
|
}
|