mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
fix(files): Only register preview service worker once when the instance is hosted at the root path
Signed-off-by: provokateurin <kate@provokateurin.de> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
This commit is contained in:
parent
5e6b36aa2a
commit
eea37f13d6
3 changed files with 11 additions and 4 deletions
|
|
@ -11,7 +11,14 @@ export default () => {
|
|||
window.addEventListener('load', async () => {
|
||||
try {
|
||||
const url = generateUrl('/apps/files/preview-service-worker.js', {}, { noRewrite: true })
|
||||
const scope = getRootUrl()
|
||||
let scope = getRootUrl()
|
||||
// If the instance is not in a subfolder an empty string will be returned.
|
||||
// The service worker registration will use the current path if it receives an empty string,
|
||||
// which will result in a service worker registration for every single path the user visits.
|
||||
if (scope === '') {
|
||||
scope = '/'
|
||||
}
|
||||
|
||||
const registration = await navigator.serviceWorker.register(url, { scope })
|
||||
logger.debug('SW registered: ', { registration })
|
||||
} catch (error) {
|
||||
|
|
|
|||
4
dist/files-init.js
vendored
4
dist/files-init.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-init.js.map
vendored
2
dist/files-init.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue