Skip to content

Commit

Permalink
Merge pull request #11228 from nextcloud/fix/11144/empty-favorite-names
Browse files Browse the repository at this point in the history
Fixes empty favorite names for trailing slashes
  • Loading branch information
nickvergessen authored Sep 20, 2018
2 parents 75ec460 + 7e92b52 commit 58e2818
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 5 deletions.
3 changes: 1 addition & 2 deletions apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
$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 = [
Expand All @@ -186,7 +185,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
'dir' => $dir,
'order' => $navBarPositionPosition,
'folderPosition' => $sortingValue,
'name' => $id,
'name' => basename($dir),
'icon' => 'files',
'quickaccesselement' => 'true'
];
Expand Down
72 changes: 69 additions & 3 deletions apps/files/tests/Controller/ViewControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,53 @@ public function testIndexWithRegularBrowser() {
'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'
],
Expand Down Expand Up @@ -303,6 +348,22 @@ public function testIndexWithRegularBrowser() {
'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' => [],
]
Expand All @@ -315,7 +376,12 @@ public function testIndexWithRegularBrowser() {
->with($this->user->getUID())
->willReturn([
'item' => [],
'folders' => [],
'folders' => [
'/test1',
'/test2/',
'/test3/sub4',
'/test5/sub6/',
],
]);

$this->assertEquals($expected, $this->viewController->index('MyDir', 'MyView'));
Expand Down

0 comments on commit 58e2818

Please sign in to comment.