diff options
author | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-02 23:21:21 +0000 |
---|---|---|
committer | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-02 23:21:21 +0000 |
commit | 38c0c73c2f60d7c63cc4da1b20b031cda5851e11 (patch) | |
tree | 68b251b2d410443ec2a81c83724aca0e9f5ec72f /engine | |
parent | c554c1b3f81011723b56b93f9fe19122a6fdba70 (diff) | |
download | elgg-38c0c73c2f60d7c63cc4da1b20b031cda5851e11.tar.gz elgg-38c0c73c2f60d7c63cc4da1b20b031cda5851e11.tar.bz2 |
Added url normalization support to elgg_register_js and elgg_register_css
git-svn-id: http://code.elgg.org/elgg/trunk@7207 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/elgglib.php | 2 | ||||
-rw-r--r-- | engine/tests/api/helpers.php | 26 |
2 files changed, 14 insertions, 14 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index e45b231d4..3f12bd10f 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -168,7 +168,7 @@ function elgg_register_external_file($type, $url, $id, $location) { $id = trim(strtolower($id)); } - $CONFIG->externals[$type][$location][$id] = $url; + $CONFIG->externals[$type][$location][$id] = elgg_normalize_url($url); return true; } diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php index 6afcd0ef8..b8c7f048d 100644 --- a/engine/tests/api/helpers.php +++ b/engine/tests/api/helpers.php @@ -71,14 +71,14 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { global $CONFIG; // specify id - $result = elgg_register_js('test1', 'key', 'footer'); + $result = elgg_register_js('//test1.com', 'key', 'footer'); $this->assertTrue($result); - $this->assertIdentical('test1', $CONFIG->externals['javascript']['footer']['key']); + $this->assertIdentical('//test1.com', $CONFIG->externals['javascript']['footer']['key']); // let Elgg pick id - $result = elgg_register_js('test2'); + $result = elgg_register_js('//test2.com'); $this->assertTrue($result); - $this->assertIdentical('test2', $CONFIG->externals['javascript']['head'][0]); + $this->assertIdentical('//test2.com', $CONFIG->externals['javascript']['head'][0]); // send a bad url $result = elgg_register_js(); @@ -92,14 +92,14 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { global $CONFIG; // specify id - $result = elgg_register_css('test1', 'key'); + $result = elgg_register_css('//test1.com', 'key'); $this->assertTrue($result); - $this->assertIdentical('test1', $CONFIG->externals['css']['head']['key']); + $this->assertIdentical('//test1.com', $CONFIG->externals['css']['head']['key']); // let Elgg pick id - $result = elgg_register_css('test2'); + $result = elgg_register_css('//test2.com'); $this->assertTrue($result); - $this->assertIdentical('test2', $CONFIG->externals['css']['head'][1]); + $this->assertIdentical('//test2.com', $CONFIG->externals['css']['head'][1]); // send a bad url $result = elgg_register_js(); @@ -112,7 +112,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { public function testElggUnregisterJS() { global $CONFIG; - $urls = array('id1' => 'url1', 'id2' => 'url2', 'id3' => 'url3'); + $urls = array('id1' => '//url1.com', 'id2' => '//url2.com', 'id3' => '//url3.com'); foreach ($urls as $id => $url) { elgg_register_js($url, $id); } @@ -121,16 +121,16 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { $this->assertTrue($result); $this->assertNULL($CONFIG->externals['javascript']['head']['id1']); - $result = elgg_unregister_js('', 'url2'); + $result = elgg_unregister_js('', '//url2.com'); $this->assertTrue($result); $this->assertNULL($CONFIG->externals['javascript']['head']['id2']); $result = elgg_unregister_js('id1'); $this->assertFalse($result); - $result = elgg_unregister_js('', 'url2'); + $result = elgg_unregister_js('', '//url2.com'); $this->assertFalse($result); - $this->assertIdentical('url3', $CONFIG->externals['javascript']['head']['id3']); + $this->assertIdentical($urls['id3'], $CONFIG->externals['javascript']['head']['id3']); } /** @@ -139,7 +139,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { public function testElggGetJS() { global $CONFIG; - $urls = array('id1' => 'url1', 'id2' => 'url2', 'id3' => 'url3'); + $urls = array('id1' => '//url1.com', 'id2' => '//url2.com', 'id3' => '//url3.com'); foreach ($urls as $id => $url) { elgg_register_js($url, $id); } |