aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/output.php4
-rw-r--r--engine/tests/api/helpers.php20
2 files changed, 22 insertions, 2 deletions
diff --git a/engine/lib/output.php b/engine/lib/output.php
index 84b012631..cac7eeb5b 100644
--- a/engine/lib/output.php
+++ b/engine/lib/output.php
@@ -161,11 +161,11 @@ function elgg_normalize_url($url) {
}
// 'example.com', 'example.com/subpage'
- elseif (preg_match("#[^/]*\.[^/]*/?#i", $url)) {
+ elseif (preg_match("#^[^/]*\.#i", $url)) {
return "http://$url";
}
- // 'pg/page/handler'
+ // 'pg/page/handler', 'mod/plugin/file.php'
else {
return elgg_get_site_url().$url;
}
diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php
index b8c7f048d..8dab74ff8 100644
--- a/engine/tests/api/helpers.php
+++ b/engine/tests/api/helpers.php
@@ -65,6 +65,26 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
}
/**
+ * Test elgg_normalize_url()
+ */
+ public function testElggNormalizeURL() {
+ $conversions = array(
+ 'http://example.com' => 'http://example.com',
+ 'https://example.com' => 'https://example.com',
+ '//example.com' => '//example.com',
+ 'example.com' => 'http://example.com',
+ 'example.com/subpage' => 'http://example.com/subpage',
+ 'pg/page/handler' => elgg_get_site_url().'pg/page/handler',
+ 'mod/plugin/file.php' => elgg_get_site_url().'mod/plugin/file.php',
+ );
+
+ foreach ($conversions as $input => $output) {
+ $this->assertIdentical($output, elgg_normalize_url($input));
+ }
+ }
+
+
+ /**
* Test elgg_register_js()
*/
public function testElggRegisterJS() {