From: Alexander Ebert Date: Sat, 21 Feb 2015 11:42:40 +0000 (+0100) Subject: Fixed some URL issues in AJAX requests X-Git-Tag: 2.1.0_RC_2~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9eec0471f725c8a943125e3061ba40e4a815aa1b;p=GitHub%2FWoltLab%2FWCF.git Fixed some URL issues in AJAX requests --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 1d74052fe3..17857954e9 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -754,6 +754,32 @@ $.extend(WCF, { } return new Blob($byteArrays, { type: contentType }); + }, + + /** + * Converts legacy URLs to the URL schema used by WCF 2.1. + * + * @param string url + * @return string + */ + convertLegacyURL: function(url) { + if (URL_LEGACY_MODE) { + return url; + } + + return url.replace(/^index\.php\/(.*?)\/\?/, function(match, controller) { + var $parts = controller.split(/([A-Z][a-z0-9]+)/); + var $controller = ''; + for (var $i = 0, $length = $parts.length; $i < $length; $i++) { + var $part = $parts[$i].trim(); + if ($part.length) { + if ($controller.length) $controller += '-'; + $controller += $part.toLowerCase(); + } + } + + return 'index.php?' + $controller + '/&'; + }); } }); @@ -2533,9 +2559,7 @@ WCF.Action.Proxy = Class.extend({ autoAbortPrevious: false }, options); - if (!URL_LEGACY_MODE) { - this.options.url = this.options.url.replace(/^index\.php\/(.*?)\/\?/, '?$1/&'); - } + this.options.url = WCF.convertLegacyURL(this.options.url); this.confirmationDialog = null; this.loading = null; @@ -8927,9 +8951,7 @@ WCF.Upload = Class.extend({ url: 'index.php/AJAXUpload/?t=' + SECURITY_TOKEN + SID_ARG_2ND }, options || { }); - if (!URL_LEGACY_MODE) { - this._options.url = this._options.url.replace(/^index\.php\/(.*?)\/\?/, '?$1/&'); - } + this._options.url = WCF.convertLegacyURL(this._options.url); // check for ajax upload support var $xhr = new XMLHttpRequest();