mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
Merge pull request #56427 from nextcloud/backport/56409/stable32
[stable32] fix(files_sharing): use webroot for public links
This commit is contained in:
commit
288f2ceb43
8 changed files with 26 additions and 12 deletions
|
|
@ -3,13 +3,27 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { generateFileUrl } from './generateUrl.ts'
|
||||
|
||||
const getCapabilities = vi.hoisted(() => vi.fn())
|
||||
vi.mock('@nextcloud/capabilities', () => ({ getCapabilities }))
|
||||
|
||||
describe('generateFileUrl', () => {
|
||||
beforeEach(() => {
|
||||
window._oc_webroot = ''
|
||||
})
|
||||
|
||||
/**
|
||||
* Regression test of https://github.com/nextcloud/server/issues/56374
|
||||
*/
|
||||
it('should work without globalscale and webroot', () => {
|
||||
window._oc_webroot = '/nextcloud'
|
||||
getCapabilities.mockReturnValue({ globalscale: null })
|
||||
const url = generateFileUrl(12345)
|
||||
expect(url).toBe('http://nextcloud.local/nextcloud/index.php/f/12345')
|
||||
})
|
||||
|
||||
it('should work without globalscale', () => {
|
||||
getCapabilities.mockReturnValue({ globalscale: null })
|
||||
const url = generateFileUrl(12345)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import { getCapabilities } from '@nextcloud/capabilities'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import { generateUrl, getBaseUrl } from '@nextcloud/router'
|
||||
|
||||
interface IGlobalScaleCapabilities {
|
||||
token?: string
|
||||
|
|
@ -14,7 +14,7 @@ interface IGlobalScaleCapabilities {
|
|||
* @param fileid - The file ID to generate the direct file link for
|
||||
*/
|
||||
export function generateFileUrl(fileid: number): string {
|
||||
const baseURL = window.location.protocol + '//' + window.location.host
|
||||
const baseURL = getBaseUrl()
|
||||
|
||||
const { globalscale } = getCapabilities() as { globalscale?: IGlobalScaleCapabilities }
|
||||
if (globalscale?.token) {
|
||||
|
|
|
|||
4
dist/1489-1489.js
vendored
4
dist/1489-1489.js
vendored
File diff suppressed because one or more lines are too long
2
dist/1489-1489.js.map
vendored
2
dist/1489-1489.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/files-reference-files.js
vendored
4
dist/files-reference-files.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-reference-files.js.map
vendored
2
dist/files-reference-files.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/files_sharing-files_sharing_tab.js
vendored
4
dist/files_sharing-files_sharing_tab.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files_sharing-files_sharing_tab.js.map
vendored
2
dist/files_sharing-files_sharing_tab.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue