From a8e8a89ade2e5fd1aed16905335fbb765fbdde67 Mon Sep 17 00:00:00 2001 From: John Molakvoæ Date: Sat, 22 Oct 2022 12:49:11 +0200 Subject: Only check unsupported browsers on user rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- core/src/main.js | 5 ----- core/src/unsupported-browser-redirect.js | 26 ++++++++++++++++++++++++++ core/src/unsupported-browser.js | 2 +- core/src/utils/RedirectUnsupportedBrowsers.js | 9 +++++---- core/src/views/UnsupportedBrowser.vue | 10 +++++++++- 5 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 core/src/unsupported-browser-redirect.js (limited to 'core/src') diff --git a/core/src/main.js b/core/src/main.js index a8abbe5ac02..ec23171b6ea 100644 --- a/core/src/main.js +++ b/core/src/main.js @@ -36,11 +36,6 @@ import './globals.js' import './jquery/index.js' import { initCore } from './init.js' import { registerAppsSlideToggle } from './OC/apps.js' -import { testSupportedBrowser } from './utils/RedirectUnsupportedBrowsers.js' - -if (!window.TESTING && !OC?.config?.no_unsupported_browser_warning) { - testSupportedBrowser() -} window.addEventListener('DOMContentLoaded', function() { initCore() diff --git a/core/src/unsupported-browser-redirect.js b/core/src/unsupported-browser-redirect.js new file mode 100644 index 00000000000..5ea64221a04 --- /dev/null +++ b/core/src/unsupported-browser-redirect.js @@ -0,0 +1,26 @@ +/** + * @copyright 2022 John Molakvoæ + * + * @author John Molakvoæ + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { testSupportedBrowser } from './utils/RedirectUnsupportedBrowsers.js' + +if (!window.TESTING && !OC?.config?.no_unsupported_browser_warning) { + testSupportedBrowser() +} diff --git a/core/src/unsupported-browser.js b/core/src/unsupported-browser.js index 59b4154ec6b..a9b44b666fc 100644 --- a/core/src/unsupported-browser.js +++ b/core/src/unsupported-browser.js @@ -1,5 +1,5 @@ /** - * @copyright 2021 John Molakvoæ + * @copyright 2022 John Molakvoæ * * @author John Molakvoæ * diff --git a/core/src/utils/RedirectUnsupportedBrowsers.js b/core/src/utils/RedirectUnsupportedBrowsers.js index dd6bb99b94d..04382722c2d 100644 --- a/core/src/utils/RedirectUnsupportedBrowsers.js +++ b/core/src/utils/RedirectUnsupportedBrowsers.js @@ -1,5 +1,5 @@ /** - * @copyright 2021 John Molakvoæ + * @copyright 2022 John Molakvoæ * * @author John Molakvoæ * @@ -19,8 +19,6 @@ * along with this program. If not, see . */ -import { generateUrl } from '@nextcloud/router' - import { supportedBrowsersRegExp } from '../services/BrowsersListService.js' import browserStorage from '../services/BrowserStorageService.js' import logger from '../logger.js' @@ -49,6 +47,9 @@ export const testSupportedBrowser = function() { // If incompatible, NOT overridden AND NOT already on the warning page, // redirect to the unsupported warning page if (window.location.pathname.indexOf(redirectPath) === -1) { - window.location = generateUrl(redirectPath) + const redirectUrl = window.location.href.replace(window.location.origin, '') + const base64Param = Buffer.from(redirectUrl).toString('base64') + history.pushState(null, null, `${redirectPath}?redirect_url=${base64Param}`) + window.location.reload() } } diff --git a/core/src/views/UnsupportedBrowser.vue b/core/src/views/UnsupportedBrowser.vue index 86e24925c32..e46c64da24c 100644 --- a/core/src/views/UnsupportedBrowser.vue +++ b/core/src/views/UnsupportedBrowser.vue @@ -1,5 +1,5 @@