From 3631bc8f393d468826b4a83fe19c2b3b0359c423 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Fri, 31 Jul 2020 08:36:27 -0700 Subject: [PATCH] restrict "share" to mobile, fixes #1505 Co-authored-by: timvisee --- app/capabilities.js | 8 +++++--- app/utils.js | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/capabilities.js b/app/capabilities.js index d37e9e05..d43a6b10 100644 --- a/app/capabilities.js +++ b/app/capabilities.js @@ -77,6 +77,7 @@ async function polyfillStreams() { export default async function getCapabilities() { const browser = browserName(); + const isMobile = /mobi|android/i.test(navigator.userAgent); const serviceWorker = 'serviceWorker' in navigator && browser !== 'edge'; let crypto = await checkCrypto(); const nativeStreams = checkStreams(); @@ -91,14 +92,15 @@ export default async function getCapabilities() { account = false; } const share = - typeof navigator.share === 'function' && locale().startsWith('en'); // en until strings merge + isMobile && + typeof navigator.share === 'function' && + locale().startsWith('en'); // en until strings merge const standalone = window.matchMedia('(display-mode: standalone)').matches || navigator.standalone; - const mobileFirefox = - browser === 'firefox' && /mobile/i.test(navigator.userAgent); + const mobileFirefox = browser === 'firefox' && isMobile; return { account, diff --git a/app/utils.js b/app/utils.js index a71cd70f..80ed462a 100644 --- a/app/utils.js +++ b/app/utils.js @@ -142,12 +142,16 @@ function openLinksInNewTab(links, should = true) { function browserName() { try { + // order of these matters if (/firefox/i.test(navigator.userAgent)) { return 'firefox'; } if (/edge/i.test(navigator.userAgent)) { return 'edge'; } + if (/edg/i.test(navigator.userAgent)) { + return 'edgium'; + } if (/trident/i.test(navigator.userAgent)) { return 'ie'; }