Permalink
Browse files

Tweaking the UriBuilder and fixing UriBuilder instantiation in UriInfo.

  • Loading branch information...
1 parent aaf156f commit 70c9017447163a15da5697744cddfab6bbc56adb @thizzle committed Feb 7, 2012
Showing with 12 additions and 6 deletions.
  1. +8 −2 src/Sonno/Uri/UriBuilder.php
  2. +4 −4 src/Sonno/Uri/UriInfo.php
@@ -50,8 +50,8 @@ public function __construct(
$requestHeaders = $request->getHeaders();
$this->scheme($request->isSecure() ? 'https' : 'http');
- if (isset($requestHeaders['Host'])) {
- $this->host($requestHeaders['Host']);
+ if (isset($requestHeaders['host'])) {
+ $this->host($requestHeaders['host']);
}
// set the port number using the one from the Request, or the default
@@ -142,6 +142,12 @@ public function path($path)
}
$currentPath = $this->_uriComponents['path'];
+
+ // reset the current path when it represents the root
+ if ($currentPath == '/') {
+ $currentPath = '';
+ }
+
$currentPath .= '/' . trim($path, '/');
$this->_uriComponents['path'] = $currentPath;
@@ -102,8 +102,8 @@ public function getAbsolutePath()
*/
public function getAbsolutePathBuilder()
{
- $builder = new UriBuilder($this->_request);
- return $builder->queryParams(null);
+ $builder = new UriBuilder($this->_config, $this->_request);
+ return $builder->replaceQuery(null);
}
/**
@@ -124,7 +124,7 @@ public function getBaseUri()
*/
public function getBaseUriBuilder()
{
- $builder = new UriBuilder($this->_request);
+ $builder = new UriBuilder($this->_config, $this->_request);
return $builder->replacePath($this->_config->getBaseUri());
}
@@ -168,7 +168,7 @@ public function getRequestUri()
*/
public function getRequestUriBuilder()
{
- $builder = new UriBuilder($this->_request);
+ $builder = new UriBuilder($this->_config, $this->_request);
return $builder;
}

0 comments on commit 70c9017

Please sign in to comment.