Filelist change dir auto-prepend slash

Prepend a slash to directories in case it was missing since many places
assume that it's there.
This commit is contained in:
Vincent Petry 2016-07-01 11:10:37 +02:00
parent 2d2d2267f7
commit 4acb06923d
2 changed files with 10 additions and 1 deletions

View File

@ -513,7 +513,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);
}
},
@ -1415,6 +1415,9 @@
this.setPageTitle();
}
if (targetDir.length > 0 && targetDir[0] !== '/') {
targetDir = '/' + targetDir;
}
this._currentDirectory = targetDir;
// legacy stuff

View File

@ -1391,6 +1391,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;