diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2022-11-03 11:53:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-03 11:53:24 +0100 |
commit | 58eb97dbf0b2ff48d416065930631e62594dc3a8 (patch) | |
tree | 1b572a3158ae2c5b2a347d2520a98e51f5b75cfc | |
parent | bc2f496690d15e0be91f44e7120b381b283edf08 (diff) | |
parent | 7c841a63171c168f8eeeaca3d5a3f47fb4b6f369 (diff) |
Merge pull request #8277 from nextcloud/backport/8136/stable22
[stable22] Handle invalid browser versions more gracefully and fix Safari iPadOS…
-rw-r--r-- | src/mixins/browserCheck.js | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/mixins/browserCheck.js b/src/mixins/browserCheck.js index c57b9a57f..bdd3c0dba 100644 --- a/src/mixins/browserCheck.js +++ b/src/mixins/browserCheck.js @@ -37,9 +37,12 @@ const browserCheck = { }, }, computed: { + parser() { + return new UAParser() + }, + browser() { - const parser = new UAParser() - return parser.getBrowser() + return this.parser.getBrowser() }, isFirefox() { @@ -61,8 +64,28 @@ const browserCheck = { return this.browser.name === 'IE' || this.browser.name === 'IEMobile' }, + browserVersion() { + if (this.browser.version) { + return this.browser.version + } + + if (this.browser.name === 'Safari') { + // Workaround for https://github.com/faisalman/ua-parser-js/issues/599 + const match = this.parser.getUA().match(' Version/([0-9.,]+) ') + if (match) { + return match[1] + } + } + + return undefined + }, + majorVersion() { - return parseInt(this.browser.version.split('.')[0], 10) + if (this.browserVersion) { + return parseInt(this.browserVersion.split('.')[0], 10) + } + + return 0 }, isFullySupported() { |