diff options
Diffstat (limited to 'engine/js/lib')
-rw-r--r-- | engine/js/lib/ajax.js | 2 | ||||
-rw-r--r-- | engine/js/lib/elgglib.js | 16 |
2 files changed, 12 insertions, 6 deletions
diff --git a/engine/js/lib/ajax.js b/engine/js/lib/ajax.js index bce0d31d3..184fd0da3 100644 --- a/engine/js/lib/ajax.js +++ b/engine/js/lib/ajax.js @@ -18,7 +18,7 @@ elgg.provide('elgg.ajax'); elgg.ajax = function(url, options) {
options = elgg.ajax.handleOptions(url, options);
- options.url = elgg.extendUrl(options.url);
+ options.url = elgg.normalize_url(options.url);
return $.ajax(options);
};
/**
diff --git a/engine/js/lib/elgglib.js b/engine/js/lib/elgglib.js index a91def2b9..32dbb1ec3 100644 --- a/engine/js/lib/elgglib.js +++ b/engine/js/lib/elgglib.js @@ -55,6 +55,10 @@ elgg.require = function(pkg) { * elgg.package = elgg.package || {};
* elgg.package.subpackage = elgg.package.subpackage || {};
* </pre>
+ *
+ * @example elgg.provide('elgg.config.translations')
+ *
+ * @param {string} pkg The package name.
*/
elgg.provide = function(pkg) {
elgg.assertTypeOf('string', pkg);
@@ -105,13 +109,15 @@ elgg.inherit = function(Child, Parent) { * @return {String} The extended url
* @private
*/
-elgg.extendUrl = function(url) {
+elgg.normalize_url = function(url) {
url = url || '';
- if(url.indexOf(elgg.config.wwwroot) == -1) {
- url = elgg.config.wwwroot + url;
+ elgg.assertTypeOf('string', url);
+
+ if(/(^(https?:)?\/\/)/.test(url)) {
+ return url;
}
- return url;
+ return elgg.config.wwwroot + url;
};
/**
@@ -177,5 +183,5 @@ elgg.register_error = function(errors, delay) { * @param {String} url The url to forward to
*/
elgg.forward = function(url) {
- location.href = elgg.extendUrl(url);
+ location.href = elgg.normalize_url(url);
};
\ No newline at end of file |