From fba1731cb4547830b3c81c3841279d086b62fc85 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 13 Aug 2019 11:57:20 -0400 Subject: [PATCH] proper safari detection in utils --- src/services/browserPlatformUtils.service.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/services/browserPlatformUtils.service.ts b/src/services/browserPlatformUtils.service.ts index e6bffcb561..9da0fa529f 100644 --- a/src/services/browserPlatformUtils.service.ts +++ b/src/services/browserPlatformUtils.service.ts @@ -24,7 +24,9 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService return this.deviceCache; } - if (navigator.userAgent.indexOf(' Firefox/') !== -1 || navigator.userAgent.indexOf(' Gecko/') !== -1) { + if (BrowserApi.isSafariApi) { + this.deviceCache = DeviceType.SafariExtension; + } else if (navigator.userAgent.indexOf(' Firefox/') !== -1 || navigator.userAgent.indexOf(' Gecko/') !== -1) { this.deviceCache = DeviceType.FirefoxExtension; } else if ((!!(window as any).opr && !!opr.addons) || !!(window as any).opera || navigator.userAgent.indexOf(' OPR/') >= 0) { @@ -33,9 +35,6 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService this.deviceCache = DeviceType.EdgeExtension; } else if (navigator.userAgent.indexOf(' Vivaldi/') !== -1) { this.deviceCache = DeviceType.VivaldiExtension; - } else if ((window as any).safari && navigator.userAgent.indexOf(' Safari/') !== -1 && - navigator.userAgent.indexOf('Chrome') === -1) { - this.deviceCache = DeviceType.SafariExtension; } else if ((window as any).chrome && navigator.userAgent.indexOf(' Chrome/') !== -1) { this.deviceCache = DeviceType.ChromeExtension; } @@ -210,7 +209,7 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService try { // Security exception may be thrown by some browsers. - if (doc.execCommand('copy') && !clearing && this.clipboardWriteCallback != null) { + if (doc.execCommand('copy') && !clearing && this.clipboardWriteCallback != null) { this.clipboardWriteCallback(text, clearMs); } } catch (e) {