From 16ffabcf6a5cbc81b902d5d148cb7f26a82e2db7 Mon Sep 17 00:00:00 2001 From: Michiel Vancoillie Date: Wed, 7 Aug 2013 20:20:16 +0200 Subject: [PATCH 1/3] Remove double slash --- src/tdt/pages/Generator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tdt/pages/Generator.php b/src/tdt/pages/Generator.php index 00a9e49..415c972 100644 --- a/src/tdt/pages/Generator.php +++ b/src/tdt/pages/Generator.php @@ -38,6 +38,7 @@ public function __construct($config = array()){ if(class_exists('\app\core\Config')){ // Get root folder for building relative URLS for assets $this->baseURL = '/'. \app\core\Config::get('general', 'subdir') . PACKAGE_PATH; + $this->baseURL = str_replace('//', '/', $this->baseURL); }else{ // Assume the example file is served $this->baseURL = '../public/'; From b7dd2a92434b072a17dcc9de63ad4496492c5f56 Mon Sep 17 00:00:00 2001 From: Michiel Vancoillie Date: Wed, 7 Aug 2013 20:28:32 +0200 Subject: [PATCH 2/3] Start slash on PHP_SELF --- src/tdt/pages/Generator.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tdt/pages/Generator.php b/src/tdt/pages/Generator.php index 415c972..d09d6b3 100644 --- a/src/tdt/pages/Generator.php +++ b/src/tdt/pages/Generator.php @@ -184,6 +184,8 @@ public function error($code, $message, $body){ private function getCurrentURI() { - return preg_replace('/index\.php$/', '', $_SERVER["PHP_SELF"]) . $_SERVER["REQUEST_URI"]; + // Start slash if PHP_SELF is empty + $uri = '/'. preg_replace('/index\.php$/', '', $_SERVER["PHP_SELF"]) . $_SERVER["REQUEST_URI"]; + return str_replace('//', '/', $uri); } } From 8c5bcf663aabf4ad2b7c2bd851dc210aeedf88e5 Mon Sep 17 00:00:00 2001 From: Michiel Vancoillie Date: Wed, 7 Aug 2013 20:41:24 +0200 Subject: [PATCH 3/3] Start slash on PHP_SELF --- src/tdt/pages/Generator.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tdt/pages/Generator.php b/src/tdt/pages/Generator.php index d09d6b3..aac9a6d 100644 --- a/src/tdt/pages/Generator.php +++ b/src/tdt/pages/Generator.php @@ -144,6 +144,7 @@ public function generate($body, $template = 'base'){ if($template == 'resource'){ $url = $this->getCurrentURI(); $url = preg_replace('/(\.about|\.html)$/', '', $url); + $url = str_replace('//', '/', $url); $data['json_link'] = $url . '.json'; $data['xml_link'] = $url . '.xml'; } @@ -184,8 +185,6 @@ public function error($code, $message, $body){ private function getCurrentURI() { - // Start slash if PHP_SELF is empty - $uri = '/'. preg_replace('/index\.php$/', '', $_SERVER["PHP_SELF"]) . $_SERVER["REQUEST_URI"]; - return str_replace('//', '/', $uri); + return preg_replace('/index\.php$/', '', $_SERVER["PHP_SELF"]) . $_SERVER["REQUEST_URI"]; } }