aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/is-popup-or-notification.js
blob: 894564def5b50313292ed35ef9d2192bb3d12d36 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * 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'.
 *
 */
module.exports = function isPopupOrNotification () {
  const url = window.location.href

  if (url.match(/popup.html(?:\?.+)*$/) ||
    url.match(/home.html(?:\?.+)*$/) || url.match(/home.html(?:#.*)*$/)) {
    return 'popup'
  } else {
    return 'notification'
  }
}