aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/output.php
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-02 19:22:35 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-02 19:22:35 +0000
commit83ed6a85ef10757d147303b391343994d0d2faf8 (patch)
tree1ca8ba79df9bf0b79d7306f0c40a9a349c6a0ca7 /engine/lib/output.php
parent3423daa3784995f25b72ebfb1e17d59f745f9354 (diff)
downloadelgg-83ed6a85ef10757d147303b391343994d0d2faf8.tar.gz
elgg-83ed6a85ef10757d147303b391343994d0d2faf8.tar.bz2
Refs #2463: Added elgg_normalize_url. forward() and add_menu() make use of it
git-svn-id: http://code.elgg.org/elgg/trunk@7194 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/output.php')
-rw-r--r--engine/lib/output.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/engine/lib/output.php b/engine/lib/output.php
index 6fd820486..707d0b79a 100644
--- a/engine/lib/output.php
+++ b/engine/lib/output.php
@@ -140,6 +140,29 @@ function elgg_format_url($url) {
}
/**
+ * Converts shorthand urls to absolute urls.
+ *
+ * If the url is already absolute or protocol-relative, no change is made.
+ *
+ * @example
+ * elgg_normalize_url(''); // 'http://my.site.com/'
+ * elgg_normalize_url('pg/dashboard'); // 'http://my.site.com/pg/dashboard'
+ * elgg_normalize_url('http://google.com/'); // no change
+ * elgg_normalize_url('//google.com/'); // no change
+ *
+ * @param string $url The URL to normalize
+ *
+ * @return string The absolute url
+ */
+function elgg_normalize_url($url) {
+ if (preg_match("#{^(https?:)?//#i", $url)) {
+ return $url;
+ }
+
+ return elgg_get_site_url().$url;
+}
+
+/**
* When given a title, returns a version suitable for inclusion in a URL
*
* @param string $title The title