aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-02 20:16:13 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-02 20:16:13 +0000
commitb314a9a072d301e2e89c4873d76429ba46e9c94a (patch)
tree1897dba2a7dd360d8487c17d63d0b621e982b4e0 /engine
parent7dd19a4cb04803f4d05fcd109b3149c6926b6558 (diff)
downloadelgg-b314a9a072d301e2e89c4873d76429ba46e9c94a.tar.gz
elgg-b314a9a072d301e2e89c4873d76429ba46e9c94a.tar.bz2
Refs #2463: Added url normalization support to output/url, output/confirmlink. Enhanced normalization to take care of urls like "example.com"
git-svn-id: http://code.elgg.org/elgg/trunk@7199 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/output.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/engine/lib/output.php b/engine/lib/output.php
index 335a53ac4..35ace7c09 100644
--- a/engine/lib/output.php
+++ b/engine/lib/output.php
@@ -155,11 +155,20 @@ function elgg_format_url($url) {
* @return string The absolute url
*/
function elgg_normalize_url($url) {
+ // 'http://example.com', 'https://example.com', '//example.com'
if (preg_match("#^(https?:)?//#i", $url)) {
return $url;
- }
+ }
+
+ // 'example.com', 'example.com/subpage'
+ elseif (preg_match("#[^/]*\.[^/]*/?#i", $url)) {
+ return "http://$url";
+ }
- return elgg_get_site_url().$url;
+ // 'pg/page/handler'
+ else {
+ return elgg_get_site_url().$url;
+ }
}
/**