Avoid double slashes in URL when trying to add an remote share

When being on a link share and clicking "Add to your ownCloud" a double slash might be inserted in the URL if the entered ownCloud host ended with a slash. Results in a server error.
This commit is contained in:
blizzz 2015-11-18 22:48:35 +01:00
parent da5285dc23
commit 5d2e1268cd
1 changed files with 5 additions and 1 deletions

View File

@ -274,8 +274,12 @@ OCA.Sharing.PublicApp = {
_saveToOwnCloud: function (remote, token, owner, name, isProtected) {
var location = window.location.protocol + '//' + window.location.host + OC.webroot;
if(remote.substr(-1) !== '/') {
remote += '/'
};
var url = remote + '/index.php/apps/files#' + 'remote=' + encodeURIComponent(location) // our location is the remote for the other server
var url = remote + 'index.php/apps/files#' + 'remote=' + encodeURIComponent(location) // our location is the remote for the other server
+ "&token=" + encodeURIComponent(token) + "&owner=" + encodeURIComponent(owner) + "&name=" + encodeURIComponent(name) + "&protected=" + isProtected;