Skip to content

Commit

Permalink
Merge pull request #45621 from nextcloud/backport/45494/stable29
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Jun 7, 2024
2 parents 8f69173 + 4cade9e commit c708848
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
4 changes: 3 additions & 1 deletion core/Controller/UnsupportedBrowserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function __construct(IRequest $request) {
public function index(): Response {
Util::addScript('core', 'unsupported-browser');
Util::addStyle('core', 'icons');
return new TemplateResponse('core', 'unsupportedbrowser', [], TemplateResponse::RENDER_AS_ERROR);

// not using RENDER_AS_ERROR as we need the JSConfigHelper for url generation
return new TemplateResponse('core', 'unsupportedbrowser', [], TemplateResponse::RENDER_AS_GUEST);
}
}
19 changes: 15 additions & 4 deletions core/src/views/UnsupportedBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@
</template>

<script>
import { generateUrl } from '@nextcloud/router'
// eslint-disable-next-line n/no-extraneous-import
import { agents } from 'caniuse-lite/dist/unpacker/agents.js'
import { generateUrl, getRootUrl } from '@nextcloud/router'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
import Web from 'vue-material-design-icons/Web.vue'
// eslint-disable-next-line n/no-extraneous-import
import { agents } from 'caniuse-lite/dist/unpacker/agents.js'
import { browserStorageKey } from '../utils/RedirectUnsupportedBrowsers.js'
import { supportedBrowsers } from '../services/BrowsersListService.js'
Expand Down Expand Up @@ -130,12 +131,22 @@ export default {
// Redirect if there is the data
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.has('redirect_url')) {
const redirectPath = Buffer.from(urlParams.get('redirect_url'), 'base64').toString() || '/'
let redirectPath = Buffer.from(urlParams.get('redirect_url'), 'base64').toString() || '/'
// remove index.php and double slashes
redirectPath = redirectPath
.replace('index.php', '')
.replace(getRootUrl(), '')
.replace(/\/\//g, '/')
// if we have a valid redirect url, use it
if (redirectPath.startsWith('/')) {
window.location = generateUrl(redirectPath)
return
}
}
// else redirect to root
window.location = generateUrl('/')
},
Expand Down
4 changes: 2 additions & 2 deletions dist/core-unsupported-browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-unsupported-browser.js.map

Large diffs are not rendered by default.

0 comments on commit c708848

Please sign in to comment.