diff options
author | Morris Jobke <hey@morrisjobke.de> | 2014-06-25 16:28:52 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-06-25 16:28:52 +0200 |
commit | a9d0e9a5d5510392b559c69cb79fbe1b64a84f03 (patch) | |
tree | 3bdabf741282a9b925424126be62a7180df44162 /apps/files_sharing | |
parent | 16396e2e3314a3dcd0fde2396212e3986e6e8ad2 (diff) | |
parent | 9de3d8225b4a0bf17bd65817eb16fdad537142df (diff) | |
download | nextcloud-server-a9d0e9a5d5510392b559c69cb79fbe1b64a84f03.tar.gz nextcloud-server-a9d0e9a5d5510392b559c69cb79fbe1b64a84f03.zip |
Merge pull request #9202 from owncloud/urlhashfix
Do not clear URL hash when no external mount params given
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/js/external.js | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/apps/files_sharing/js/external.js b/apps/files_sharing/js/external.js index 5c476b2d43d..a142819b112 100644 --- a/apps/files_sharing/js/external.js +++ b/apps/files_sharing/js/external.js @@ -8,13 +8,6 @@ * */ (function () { - var getParameterByName = function (query, name) { - name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - var regex = new RegExp("[\\#&]" + name + "=([^&#]*)"), - results = regex.exec(query); - return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); - }; - var addExternalShare = function (remote, token, owner, name, password) { return $.post(OC.generateUrl('apps/files_sharing/external'), { remote: remote, @@ -25,7 +18,16 @@ }); }; - var showAddExternalDialog = function (remote, token, owner, name, passwordProtected) { + /** + * Shows "add external share" dialog. + * + * @param {String} remote remote server URL + * @param {String} owner owner name + * @param {String} name name of the shared folder + * @param {String} token authentication token + * @param {bool} passwordProtected true if the share is password protected + */ + OCA.Sharing.showAddExternalDialog = function (remote, token, owner, name, passwordProtected) { var remoteClean = (remote.substr(0, 8) === 'https://') ? remote.substr(8) : remote.substr(7); var callback = function (add, password) { password = password || ''; @@ -47,25 +49,23 @@ , 'Add Share', callback, true, 'Password', true); } }; - - OCA.Sharing.showAddExternalDialog = function (hash) { - var remote = getParameterByName(hash, 'remote'); - var owner = getParameterByName(hash, 'owner'); - var name = getParameterByName(hash, 'name'); - var token = getParameterByName(hash, 'token'); - var passwordProtected = parseInt(getParameterByName(hash, 'protected'), 10); - - if (remote && token && owner && name) { - showAddExternalDialog(remote, token, owner, name, passwordProtected); - } - }; })(); $(document).ready(function () { // FIXME: HACK: do not init when running unit tests, need a better way if (!window.TESTING && OCA.Files) {// only run in the files app - var hash = location.hash; - location.hash = ''; - OCA.Sharing.showAddExternalDialog(hash); + var params = OC.Util.History.parseUrlQuery(); + if (params.remote && params.token && params.owner && params.name) { + // clear hash, it is unlikely that it contain any extra parameters + location.hash = ''; + params.passwordProtected = parseInt(params.passwordProtected, 10) === 1; + OCA.Sharing.showAddExternalDialog( + params.remote, + params.token, + params.owner, + params.name, + params.passwordProtected + ); + } } }); |