make_http function

This commit is contained in:
Shish 2009-07-24 08:08:29 +01:00
parent 52ba270e78
commit ecef1edb14
3 changed files with 15 additions and 4 deletions

View File

@ -54,7 +54,7 @@ class RSS_Images extends SimpleExtension {
$data = "";
foreach($images as $image) {
$link = make_link("post/view/{$image->id}");
$link = make_http(make_link("post/view/{$image->id}"));
$tags = $image->get_tag_list();
$owner = $image->get_owner();
$thumb_url = $image->get_thumb_link();

View File

@ -33,9 +33,7 @@ define('ADMIN_PASS', "demo");
*/
class SCoreWebTestCase extends WebTestCase {
protected function get_page($page) {
$url = "http://".$_SERVER["HTTP_HOST"].get_base_href().'/'.make_link($page);
$url = str_replace("/./", "/", $url);
$raw = $this->get($url);
$raw = $this->get(make_http(make_link($url)));
$this->assertNoText("Exception:");
$this->assertNoText("Error:");
$this->assertNoText("Warning:");

View File

@ -127,6 +127,19 @@ function make_link($page=null, $query=null) {
}
}
/**
* Turn a relative link into an absolute one, including hostname
*
* @retval string
*/
function make_http($link) {
if(strpos($link, "ttp://") > 0) return $link;
if($link[0] != '/') $link = get_base_href().'/'.$link;
$link = "http://".$_SERVER["HTTP_HOST"].$link;
$link = str_replace("/./", "/", $link);
return $link;
}
/**
* Make a link to a static file in the current theme's
* directory