src/Control/HTTPRequest.php
public function setUrl($url)
    {
        $this->url = $url;

        // Normalize URL if its relative (strictly speaking), or has leading slashes
        if (Director::is_relative_url($url) || preg_match('/^\//', $url)) {
            $this->url = preg_replace(array('/\/+/','/^\//', '/\/$/'), array('/','',''), $this->url);
        }
        if (preg_match('/^(.*)\.([A-Za-z][A-Za-z0-9]*)$/', $this->url, $matches)) {
            $this->url = $matches[1];
            $this->extension = $matches[2];
        }
        if ($this->url) {
            $this->dirParts = preg_split('|/+|', $this->url);
        } else {
            $this->dirParts = array();
        }

        return $this;
    }
public function setUrl($url)
    {
        $this->url = $url;

        // Normalize URL if its relative (strictly speaking), or has leading slashes
        if (Director::is_relative_url($url) || preg_match('/^\//', $url)) {
            $this->url = preg_replace(array('/\/+/','/^\//', '/\/$/'), array('/','',''), $this->url);
        }
        if (preg_match('/^(.*)\.([A-Za-z][A-Za-z0-9]*)$/', $this->url, $matches)) {
            $this->url = $matches[1];
            $this->extension = $matches[2];
        }
        if ($this->url) {
            $this->dirParts = preg_split('|/+|', $this->url);
        } else {
            $this->dirParts = array();
        }

        return $this;
    }
public function setUrl ( $ url ) { $ this -> url = $ url ; // Normalize URL if its relative (strictly speaking), or has leading slashes if ( Director :: is_relative_url ( $ url ) || preg_match ( '/^\//' , $ url ) ) { $ this -> url = preg_replace ( array ( '/\/+/' , '/^\//' , '/\/$/' ) , array ( '/' , '' , '' ) , $ this -> url ) ; } if ( preg_match ( '/^(.*)\.([A-Za-z][A-Za-z0-9]*)$/' , $ this -> url , $ matches ) ) { $ this -> url = $ matches [ 1 ] ; $ this -> extension = $ matches [ 2 ] ; } if ( $ this -> url ) { $ this -> dirParts = preg_split ( '|/+|' , $ this -> url ) ; } else { $ this -> dirParts = array ( ) ; } return $ this ; }
Allow the setting of a URL

This is here so that RootURLController can change the URL of the request
without us loosing all the other info attached (like headers)

@param string $url The new URL
@return HTTPRequest The updated request
Allow the setting of a URL