This commit is contained in:
Damian Mooyman 2014-07-31 17:05:57 +12:00
parent c02ff14db8
commit a89dbd29e1
3 changed files with 1 additions and 11 deletions

View File

@ -425,7 +425,7 @@ class Director implements TemplateGlobalProvider {
} }
if(substr($url,0,4) != "http") { if(substr($url,0,4) != "http") {
if(strpos($url, '/') !== 0) $url = Director::baseURL() . $url; if($url[0] != "/") $url = Director::baseURL() . $url;
// Sometimes baseURL() can return a full URL instead of just a path // Sometimes baseURL() can return a full URL instead of just a path
if(substr($url,0,4) != "http") $url = self::protocolAndHost() . $url; if(substr($url,0,4) != "http") $url = self::protocolAndHost() . $url;
} }

View File

@ -97,9 +97,6 @@ class DirectorTest extends SapphireTest {
$_SERVER['REQUEST_URI'] = "$rootURL/mysite/sub-page/"; $_SERVER['REQUEST_URI'] = "$rootURL/mysite/sub-page/";
Config::inst()->update('Director', 'alternate_base_url', '/mysite/'); Config::inst()->update('Director', 'alternate_base_url', '/mysite/');
//test empty URL
$this->assertEquals($rootURL, Director::absoluteURL(''));
// Test already absolute url // Test already absolute url
$this->assertEquals($rootURL, Director::absoluteURL($rootURL)); $this->assertEquals($rootURL, Director::absoluteURL($rootURL));
$this->assertEquals($rootURL, Director::absoluteURL($rootURL, true)); $this->assertEquals($rootURL, Director::absoluteURL($rootURL, true));
@ -140,7 +137,6 @@ class DirectorTest extends SapphireTest {
Config::inst()->update('Director', 'alternate_base_url', 'http://www.example.org/'); Config::inst()->update('Director', 'alternate_base_url', 'http://www.example.org/');
$this->assertEquals('http://www.example.org/', Director::baseURL()); $this->assertEquals('http://www.example.org/', Director::baseURL());
$this->assertEquals('http://www.example.org/', Director::absoluteBaseURL()); $this->assertEquals('http://www.example.org/', Director::absoluteBaseURL());
$this->assertEquals('http://www.example.org/', Director::absoluteURL(''));
$this->assertEquals('http://www.example.org/subfolder/test', Director::absoluteURL('subfolder/test')); $this->assertEquals('http://www.example.org/subfolder/test', Director::absoluteURL('subfolder/test'));
// Setting it to false restores functionality // Setting it to false restores functionality

View File

@ -161,12 +161,6 @@ class HTTPTest extends SapphireTest {
public function testAbsoluteURLsAttributes() { public function testAbsoluteURLsAttributes() {
$this->withBaseURL('http://www.silverstripe.org/', function($test){ $this->withBaseURL('http://www.silverstripe.org/', function($test){
//empty links
$test->assertEquals(
'<a href="http://www.silverstripe.org/">test</a>',
HTTP::absoluteURLs('<a href="">test</a>')
);
// links // links
$test->assertEquals( $test->assertEquals(
'<a href=\'http://www.silverstripe.org/blog/\'>SS Blog</a>', '<a href=\'http://www.silverstripe.org/blog/\'>SS Blog</a>',