Merge pull request #25325 from owncloud/filelist-prependslash

Filelist change dir auto-prepend slash
This commit is contained in:
Vincent Petry 2016-07-06 12:44:03 +02:00 committed by GitHub
commit e0b5a6456e
2 changed files with 10 additions and 1 deletions

View File

@ -513,7 +513,7 @@
* Event handler for when the URL changed * Event handler for when the URL changed
*/ */
_onUrlChanged: function(e) { _onUrlChanged: function(e) {
if (e && e.dir) { if (e && _.isString(e.dir)) {
this.changeDirectory(e.dir, false, true); this.changeDirectory(e.dir, false, true);
} }
}, },
@ -1429,6 +1429,9 @@
this.setPageTitle(); this.setPageTitle();
} }
if (targetDir.length > 0 && targetDir[0] !== '/') {
targetDir = '/' + targetDir;
}
this._currentDirectory = targetDir; this._currentDirectory = targetDir;
// legacy stuff // legacy stuff

View File

@ -1416,6 +1416,12 @@ describe('OCA.Files.FileList tests', function() {
setDirSpy.restore(); setDirSpy.restore();
getFolderContentsStub.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() { describe('breadcrumb events', function() {
var deferredList; var deferredList;