aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Weimann <mail@michael-weimann.eu>2018-09-14 22:06:56 +0200
committerMichael Weimann <mail@michael-weimann.eu>2018-09-19 17:43:55 +0200
commit7e92b52974371bae4f69b74d26e3886f45102e39 (patch)
tree6a18bdabc5e407e4e9e5d92e975df0ebd1b3bcb4
parent6112adfe064afbad17c485954d22e3947fe8ed13 (diff)
downloadnextcloud-server-7e92b52974371bae4f69b74d26e3886f45102e39.tar.gz
nextcloud-server-7e92b52974371bae4f69b74d26e3886f45102e39.zip
Fixes empty favorite names for trailing slashes
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
-rw-r--r--apps/files/lib/Controller/ViewController.php3
-rw-r--r--apps/files/tests/Controller/ViewControllerTest.php72
2 files changed, 70 insertions, 5 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 0655718f8c1..d91d3b9db4c 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -176,7 +176,6 @@ class ViewController extends Controller {
$currentCount = 0;
foreach ($favElements['folders'] as $dir) {
- $id = substr($dir, strrpos($dir, '/') + 1, strlen($dir));
$link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']);
$sortingValue = ++$currentCount;
$element = [
@@ -186,7 +185,7 @@ class ViewController extends Controller {
'dir' => $dir,
'order' => $navBarPositionPosition,
'folderPosition' => $sortingValue,
- 'name' => $id,
+ 'name' => basename($dir),
'icon' => 'files',
'quickaccesselement' => 'true'
];
diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php
index 7dc99409800..f11a6faf863 100644
--- a/apps/files/tests/Controller/ViewControllerTest.php
+++ b/apps/files/tests/Controller/ViewControllerTest.php
@@ -176,8 +176,53 @@ class ViewControllerTest extends TestCase {
'active' => false,
'icon' => '',
'type' => 'link',
- 'classes' => '',
- 'sublist' => [],
+ 'classes' => 'collapsible',
+ 'sublist' => [
+ [
+ 'id' => '-test1',
+ 'view' => 'files',
+ 'href' => '',
+ 'dir' => '/test1',
+ 'order' => 6,
+ 'folderPosition' => 1,
+ 'name' => 'test1',
+ 'icon' => 'files',
+ 'quickaccesselement' => 'true',
+ ],
+ [
+ 'name' => 'test2',
+ 'id' => '-test2-',
+ 'view' => 'files',
+ 'href' => '',
+ 'dir' => '/test2/',
+ 'order' => 7,
+ 'folderPosition' => 2,
+ 'icon' => 'files',
+ 'quickaccesselement' => 'true',
+ ],
+ [
+ 'name' => 'sub4',
+ 'id' => '-test3-sub4',
+ 'view' => 'files',
+ 'href' => '',
+ 'dir' => '/test3/sub4',
+ 'order' => 8,
+ 'folderPosition' => 3,
+ 'icon' => 'files',
+ 'quickaccesselement' => 'true',
+ ],
+ [
+ 'name' => 'sub6',
+ 'id' => '-test5-sub6-',
+ 'view' => 'files',
+ 'href' => '',
+ 'dir' => '/test5/sub6/',
+ 'order' => 9,
+ 'folderPosition' => 4,
+ 'icon' => 'files',
+ 'quickaccesselement' => 'true',
+ ],
+ ],
'defaultExpandedState' => false,
'expandedState' => 'show_Quick_Access'
],
@@ -303,6 +348,22 @@ class ViewControllerTest extends TestCase {
'id' => 'shareoverview',
'content' => null,
],
+ '-test1' => [
+ 'id' => '-test1',
+ 'content' => '',
+ ],
+ '-test2-' => [
+ 'id' => '-test2-',
+ 'content' => '',
+ ],
+ '-test3-sub4' => [
+ 'id' => '-test3-sub4',
+ 'content' => '',
+ ],
+ '-test5-sub6-' => [
+ 'id' => '-test5-sub6-',
+ 'content' => '',
+ ],
],
'hiddenFields' => [],
]
@@ -315,7 +376,12 @@ class ViewControllerTest extends TestCase {
->with($this->user->getUID())
->willReturn([
'item' => [],
- 'folders' => [],
+ 'folders' => [
+ '/test1',
+ '/test2/',
+ '/test3/sub4',
+ '/test5/sub6/',
+ ],
]);
$this->assertEquals($expected, $this->viewController->index('MyDir', 'MyView'));