summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-02-20 13:36:38 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-02-20 13:36:38 +0100
commit7cb25149c8514af776d40e57ebd5ebbb8032db3d (patch)
tree166f0c0d757beb2f5b4f589b29ab42a4747e20b4
parent79ef5eda9688c998a51bfbb3f24f5274cc83bcc2 (diff)
parentb7ff0d44d8859ee363f8afd620bf0182c626ddbc (diff)
downloadnextcloud-server-7cb25149c8514af776d40e57ebd5ebbb8032db3d.tar.gz
nextcloud-server-7cb25149c8514af776d40e57ebd5ebbb8032db3d.zip
Merge pull request #13645 from owncloud/fix-breadcrumb-backslash
Parse backslash as directory separator in breadcrumb
-rw-r--r--apps/files/js/breadcrumb.js1
-rw-r--r--apps/files/js/filelist.js1
-rw-r--r--apps/files/tests/js/breadcrumbSpec.js25
-rw-r--r--apps/files/tests/js/filelistSpec.js6
4 files changed, 32 insertions, 1 deletions
diff --git a/apps/files/js/breadcrumb.js b/apps/files/js/breadcrumb.js
index 5cea2639c7d..364475e4a4f 100644
--- a/apps/files/js/breadcrumb.js
+++ b/apps/files/js/breadcrumb.js
@@ -67,6 +67,7 @@
* @param dir path to be displayed as breadcrumb
*/
setDirectory: function(dir) {
+ dir = dir.replace(/\\/g, '/');
dir = dir || '/';
if (dir !== this.dir) {
this.dir = dir;
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index c5c665cee77..e5634323ef1 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -1009,6 +1009,7 @@
* @param changeUrl true to also update the URL, false otherwise (default)
*/
_setCurrentDir: function(targetDir, changeUrl) {
+ targetDir = targetDir.replace(/\\/g, '/');
var previousDir = this.getCurrentDirectory(),
baseDir = OC.basename(targetDir);
diff --git a/apps/files/tests/js/breadcrumbSpec.js b/apps/files/tests/js/breadcrumbSpec.js
index 30784fd70ad..a26f0176f15 100644
--- a/apps/files/tests/js/breadcrumbSpec.js
+++ b/apps/files/tests/js/breadcrumbSpec.js
@@ -93,6 +93,31 @@ describe('OCA.Files.BreadCrumb tests', function() {
expect($crumbs.eq(3).find('img').length).toEqual(0);
expect($crumbs.eq(3).attr('data-dir')).toEqual('/somedir/with space/abc');
});
+ it('Renders backslashes as regular directory separator', function() {
+ var $crumbs;
+ bc.setDirectory('/somedir\\with/mixed\\separators');
+ $crumbs = bc.$el.find('.crumb');
+ expect($crumbs.length).toEqual(5);
+ expect($crumbs.eq(0).find('a').attr('href')).toEqual('/#0');
+ expect($crumbs.eq(0).find('img').length).toEqual(1);
+ expect($crumbs.eq(0).attr('data-dir')).toEqual('/');
+
+ expect($crumbs.eq(1).find('a').attr('href')).toEqual('/somedir#1');
+ expect($crumbs.eq(1).find('img').length).toEqual(0);
+ expect($crumbs.eq(1).attr('data-dir')).toEqual('/somedir');
+
+ expect($crumbs.eq(2).find('a').attr('href')).toEqual('/somedir/with#2');
+ expect($crumbs.eq(2).find('img').length).toEqual(0);
+ expect($crumbs.eq(2).attr('data-dir')).toEqual('/somedir/with');
+
+ expect($crumbs.eq(3).find('a').attr('href')).toEqual('/somedir/with/mixed#3');
+ expect($crumbs.eq(3).find('img').length).toEqual(0);
+ expect($crumbs.eq(3).attr('data-dir')).toEqual('/somedir/with/mixed');
+
+ expect($crumbs.eq(4).find('a').attr('href')).toEqual('/somedir/with/mixed/separators#4');
+ expect($crumbs.eq(4).find('img').length).toEqual(0);
+ expect($crumbs.eq(4).attr('data-dir')).toEqual('/somedir/with/mixed/separators');
+ });
});
describe('Events', function() {
it('Calls onClick handler when clicking on a crumb', function() {
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 59e3f8a9d4e..d44365f6351 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -1221,7 +1221,7 @@ describe('OCA.Files.FileList tests', function() {
"Content-Type": "application/json"
},
JSON.stringify(data)
- ]);
+ ]);
});
it('fetches file list from server and renders it when reload() is called', function() {
fileList.reload();
@@ -1242,6 +1242,10 @@ describe('OCA.Files.FileList tests', function() {
expect(OC.parseQueryString(query)).toEqual({'dir': '/anothersubdir', sort: 'name', sortdirection: 'asc'});
fakeServer.respond();
});
+ it('converts backslashes to slashes when calling changeDirectory()', function() {
+ fileList.changeDirectory('/another\\subdir');
+ expect(fileList.getCurrentDirectory()).toEqual('/another/subdir');
+ });
it('switches to root dir when current directory does not exist', function() {
fakeServer.respondWith(/\/index\.php\/apps\/files\/ajax\/list.php\?dir=%2funexist/, [
404, {