diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-07-07 12:59:23 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-07-07 12:59:23 +0200 |
commit | 1698f2d8ab9a214206a7836dd8002b6b5cc8f465 (patch) | |
tree | 5ae9c6f7a99f632590b706ce452124b4212561ff | |
parent | e7302a83f6dc1c52d806eb1e74972337719cbb99 (diff) | |
download | nextcloud-server-1698f2d8ab9a214206a7836dd8002b6b5cc8f465.tar.gz nextcloud-server-1698f2d8ab9a214206a7836dd8002b6b5cc8f465.zip |
[stable9] Filelist change dir auto-prepend slash (#25378)
* Filelist change dir auto-prepend slash
Prepend a slash to directories in case it was missing since many places
assume that it's there.
* Fix js unit test in filelist spec
-rw-r--r-- | apps/files/js/filelist.js | 5 | ||||
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index e3f1a1ed02c..7e65bf46e30 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -481,7 +481,7 @@ * Event handler for when the URL changed */ _onUrlChanged: function(e) { - if (e && e.dir) { + if (e && _.isString(e.dir)) { this.changeDirectory(e.dir, false, true); } }, @@ -1358,6 +1358,9 @@ this.setPageTitle(); } + if (targetDir.length > 0 && targetDir[0] !== '/') { + targetDir = '/' + targetDir; + } this._currentDirectory = targetDir; // legacy stuff diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 7ca6c4b16f9..8b3f6aa28f0 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -1340,9 +1340,9 @@ describe('OCA.Files.FileList tests', function() { }); it('allows paths with dotdot at the beginning or end', function() { _.each([ - '..abc', - 'def..', - '...' + '/..abc', + '/def..', + '/...' ], function(path) { fileList.changeDirectory(path); expect(fileList.getCurrentDirectory()).toEqual(path); @@ -1396,6 +1396,12 @@ describe('OCA.Files.FileList tests', function() { setDirSpy.restore(); getFolderContentsStub.restore(); }); + it('prepends a slash to directory if none was given', function() { + fileList.changeDirectory(''); + expect(fileList.getCurrentDirectory()).toEqual('/'); + fileList.changeDirectory('noslash'); + expect(fileList.getCurrentDirectory()).toEqual('/noslash'); + }); }); describe('breadcrumb events', function() { var deferredList; |