From 90f3b87f352a98dd5890330d7f48ed2a558a65c2 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 14 Oct 2008 18:47:38 +0000 Subject: [PATCH] ENHANCEMENT Making URL accessible through HTTPRequest->getURL() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64223 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/control/HTTPRequest.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/control/HTTPRequest.php b/core/control/HTTPRequest.php index e351db6b7..08bb576eb 100644 --- a/core/control/HTTPRequest.php +++ b/core/control/HTTPRequest.php @@ -16,6 +16,11 @@ */ class HTTPRequest extends Object implements ArrayAccess { + /** + * @var string $url + */ + protected $url; + /** * The non-extension parts of the passed URL as an array, originally exploded by the "/" separator. * All elements of the URL are loaded in here, @@ -186,6 +191,13 @@ class HTTPRequest extends Object implements ArrayAccess { if(isset($this->headers[$header])) unset($this->headers[$header]); } + /** + * @return string + */ + function getURL() { + return $this->url; + } + /** * Enables the existence of a key-value pair in the request to be checked using * array syntax, so isset($request['title']) will check for $_POST['title'] and $_GET['title] @@ -225,13 +237,13 @@ class HTTPRequest extends Object implements ArrayAccess { function __construct($httpMethod, $url, $getVars = array(), $postVars = array(), $body = null) { $this->httpMethod = strtoupper(self::detect_method($httpMethod, $postVars)); - $url = preg_replace(array('/\/+/','/^\//', '/\/$/'),array('/','',''), $url); + $this->url = preg_replace(array('/\/+/','/^\//', '/\/$/'),array('/','',''), $url); if(preg_match('/^(.*)\.([A-Za-z][A-Za-z0-9]*)$/', $url, $matches)) { $url = $matches[1]; $this->extension = $matches[2]; } - if($url) $this->dirParts = split('/+', $url); + if($this->url) $this->dirParts = split('/+', $this->url); else $this->dirParts = array(); $this->getVars = (array)$getVars;