Development

- Optimized Uri class.
- Request class now uses SimpleRouter to get default-namespace as was
originally the intended behavior.
- Documentation changes.
This commit is contained in:
Simon Sessingø
2017-11-26 18:03:14 +01:00
parent 0856caa9de
commit 05f2493304
5 changed files with 43 additions and 70 deletions
+10 -18
View File
@@ -6,20 +6,20 @@ class Uri
{
private $originalUrl;
private $data = [
'scheme',
'host',
'port',
'user',
'pass',
'path',
'query',
'fragment',
'scheme' => '',
'host' => '',
'port' => '',
'user' => '',
'pass' => '',
'path' => '',
'query' => '',
'fragment' => '',
];
public function __construct($url)
{
$this->originalUrl = $url;
$this->data = array_merge($this->data, $this->parseUrl(urldecode($url)));
$this->data = $this->parseUrl($url) + $this->data;
if (isset($this->data['path']) === true && $this->data['path'] !== '/') {
$this->data['path'] = rtrim($this->data['path'], '/') . '/';
@@ -134,15 +134,7 @@ class Uri
*/
public function parseUrl($url, $component = -1)
{
$encodedUrl = preg_replace_callback(
'%[^:/@?&=#]+%u',
function ($matches) {
return urlencode($matches[0]);
},
$url
);
$parts = parse_url($encodedUrl, $component);
$parts = parse_url(urlencode($url), $component);
if ($parts === false) {
throw new \InvalidArgumentException('Malformed URL: ' . $url);