|
49 | 49 | </template> |
50 | 50 |
|
51 | 51 | <script> |
52 | | -import { generateUrl } from '@nextcloud/router' |
| 52 | +// eslint-disable-next-line n/no-extraneous-import |
| 53 | +import { agents } from 'caniuse-lite/dist/unpacker/agents.js' |
| 54 | +import { generateUrl, getRootUrl } from '@nextcloud/router' |
53 | 55 | import { translate as t, translatePlural as n } from '@nextcloud/l10n' |
| 56 | +
|
54 | 57 | import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' |
55 | 58 | import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js' |
56 | 59 | import Web from 'vue-material-design-icons/Web.vue' |
57 | | -// eslint-disable-next-line n/no-extraneous-import |
58 | | -import { agents } from 'caniuse-lite/dist/unpacker/agents.js' |
59 | 60 |
|
60 | 61 | import { browserStorageKey } from '../utils/RedirectUnsupportedBrowsers.js' |
61 | 62 | import { supportedBrowsers } from '../services/BrowsersListService.js' |
@@ -130,12 +131,22 @@ export default { |
130 | 131 | // Redirect if there is the data |
131 | 132 | const urlParams = new URLSearchParams(window.location.search) |
132 | 133 | if (urlParams.has('redirect_url')) { |
133 | | - const redirectPath = Buffer.from(urlParams.get('redirect_url'), 'base64').toString() || '/' |
| 134 | + let redirectPath = Buffer.from(urlParams.get('redirect_url'), 'base64').toString() || '/' |
| 135 | +
|
| 136 | + // remove index.php and double slashes |
| 137 | + redirectPath = redirectPath |
| 138 | + .replace('index.php', '') |
| 139 | + .replace(getRootUrl(), '') |
| 140 | + .replace(/\/\//g, '/') |
| 141 | +
|
| 142 | + // if we have a valid redirect url, use it |
134 | 143 | if (redirectPath.startsWith('/')) { |
135 | 144 | window.location = generateUrl(redirectPath) |
136 | 145 | return |
137 | 146 | } |
138 | 147 | } |
| 148 | +
|
| 149 | + // else redirect to root |
139 | 150 | window.location = generateUrl('/') |
140 | 151 | }, |
141 | 152 |
|
|
0 commit comments