mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
fix: Replace the deprecated direct download link with the public DAV endpoint
Follow-up of #48098 Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
parent
009d0c550c
commit
ec1db0c32a
3 changed files with 15 additions and 10 deletions
|
|
@ -149,10 +149,7 @@ class DefaultPublicShareTemplateProvider implements IPublicShareTemplateProvider
|
|||
$headerActions = [];
|
||||
if ($view !== 'public-file-drop' && !$share->getHideDownload()) {
|
||||
// The download URL is used for the "download" header action as well as in some cases for the direct link
|
||||
$downloadUrl = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', [
|
||||
'token' => $token,
|
||||
'filename' => ($shareNode instanceof File) ? $shareNode->getName() : null,
|
||||
]);
|
||||
$downloadUrl = $this->urlGenerator->getAbsoluteURL('/public.php/dav/files/' . $token . '/?accept=zip');
|
||||
|
||||
// If not a file drop, then add the download header action
|
||||
$headerActions[] = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $downloadUrl, 0, (string)$shareNode->getSize());
|
||||
|
|
|
|||
|
|
@ -261,8 +261,12 @@ class ShareControllerTest extends \Test\TestCase {
|
|||
['files_sharing.sharecontroller.showShare', ['token' => 'token'], 'shareUrl'],
|
||||
// this share is not an image to the default preview is used
|
||||
['files_sharing.PublicPreview.getPreview', ['x' => 256, 'y' => 256, 'file' => $share->getTarget(), 'token' => 'token'], 'previewUrl'],
|
||||
// for the direct link
|
||||
['files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename ], 'downloadUrl'],
|
||||
]);
|
||||
|
||||
$this->urlGenerator->expects($this->once())
|
||||
->method('getAbsoluteURL')
|
||||
->willReturnMap([
|
||||
['/public.php/dav/files/token/?accept=zip', 'downloadUrl'],
|
||||
]);
|
||||
|
||||
$this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true);
|
||||
|
|
@ -552,8 +556,12 @@ class ShareControllerTest extends \Test\TestCase {
|
|||
['files_sharing.sharecontroller.showShare', ['token' => 'token'], 'shareUrl'],
|
||||
// this share is not an image to the default preview is used
|
||||
['files_sharing.PublicPreview.getPreview', ['x' => 256, 'y' => 256, 'file' => $share->getTarget(), 'token' => 'token'], 'previewUrl'],
|
||||
// for the direct link
|
||||
['files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename ], 'downloadUrl'],
|
||||
]);
|
||||
|
||||
$this->urlGenerator->expects($this->once())
|
||||
->method('getAbsoluteURL')
|
||||
->willReturnMap([
|
||||
['/public.php/dav/files/token/?accept=zip', 'downloadUrl'],
|
||||
]);
|
||||
|
||||
$this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ describe('files_sharing: Public share - header actions menu', { testIsolation: t
|
|||
cy.findByRole('menuitem', { name: 'Direct link' })
|
||||
.should('be.visible')
|
||||
.and('have.attr', 'href')
|
||||
.then((attribute) => expect(attribute).to.match(/^http:\/\/.+\/download$/))
|
||||
.then((attribute) => expect(attribute).to.match(new RegExp(`^${Cypress.env('baseUrl')}/public.php/dav/files/.+/?accept=zip$`)))
|
||||
// see menu closes on click
|
||||
cy.findByRole('menuitem', { name: 'Direct link' })
|
||||
.click()
|
||||
|
|
@ -188,7 +188,7 @@ describe('files_sharing: Public share - header actions menu', { testIsolation: t
|
|||
cy.findByRole('menuitem', { name: 'Direct link' })
|
||||
.should('be.visible')
|
||||
.and('have.attr', 'href')
|
||||
.then((attribute) => expect(attribute).to.match(/^http:\/\/.+\/download$/))
|
||||
.then((attribute) => expect(attribute).to.match(new RegExp(`^${Cypress.env('baseUrl')}/public.php/dav/files/.+/?accept=zip$`)))
|
||||
// See remote share works
|
||||
cy.findByRole('menuitem', { name: /Add to your/i })
|
||||
.should('be.visible')
|
||||
|
|
|
|||
Loading…
Reference in a new issue