Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Use new DAV endpoint in web UI file list and upload #33544

Merged
merged 2 commits into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,8 @@
encodedPath += '/' + encodeURIComponent(section);
}
});
return OC.linkToRemoteBase('webdav') + encodedPath;
var uid = encodeURIComponent(OC.getCurrentUser().uid);
return OC.linkToRemoteBase('dav') + '/files/' + uid + encodedPath;
},

/**
Expand Down
23 changes: 23 additions & 0 deletions apps/files/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,29 @@ describe('OCA.Files.FileList tests', function() {
.toEqual(OC.webroot + '/index.php/apps/files/ajax/test.php?a=1&b=x%20y');
});
});
describe('Upload Url', function() {
var testPath;
beforeEach(function() {
currentUserStub = sinon.stub(OC, 'getCurrentUser').returns({uid: 'test@#?%test'});
testPath = 'path/to sp@ce/a@b#?%/x';
});
afterEach(function() {
currentUserStub.restore();
});
it('returns correct upload URL for single files with provided dir', function() {
expect(fileList.getUploadUrl('some file.txt', testPath))
.toEqual(OC.webroot + '/remote.php/dav/files/test%40%23%3F%25test/path/to%20sp%40ce/a%40b%23%3F%25/x/some%20file.txt');
});
it('returns correct upload URL with current list dir for single files when no dir argument was provided', function() {
expect(fileList.getUploadUrl('some file.txt'))
.toEqual(OC.webroot + '/remote.php/dav/files/test%40%23%3F%25test/subdir/some%20file.txt');
});
it('returns correct upload URL with current list dir when in root for single files when no dir argument was provided', function() {
$('#dir').val('/');
expect(fileList.getUploadUrl('some file.txt'))
.toEqual(OC.webroot + '/remote.php/dav/files/test%40%23%3F%25test/some%20file.txt');
});
});
describe('File selection', function() {
beforeEach(function() {
fileList.setFiles(testFiles);
Expand Down
2 changes: 1 addition & 1 deletion core/js/files/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@

var client = new OC.Files.Client({
host: OC.getHost(),
root: OC.linkToRemoteBase('webdav'),
root: OC.linkToRemoteBase('dav') + '/files/' + encodeURIComponent(OC.getCurrentUser().uid) + '/',
useHTTPS: OC.getProtocol() === 'https'
});
OC.Files._defaultClient = client;
Expand Down
2 changes: 1 addition & 1 deletion core/js/tests/specs/files/clientSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ describe('OC.Files.Client tests', function() {

expect(propFindStub.calledOnce).toEqual(true);
expect(propFindStub.getCall(0).args[0])
.toEqual('https://somehost:8080/owncloud/remote.php/webdav/path/to%20sp%40ce/a%40b%23%3F%25/x');
.toEqual('https://somehost:8080/owncloud/remote.php/dav/files/test%40%23%3F%25test/path/to%20sp%40ce/a%40b%23%3F%25/x');
});
});
});