Skip to content

Commit

Permalink
RequestFactory: removed $url->canonicalize()
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 26, 2014
1 parent 4a29834 commit 5fe8503
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/Http/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,9 @@ public function createHttpRequest()

$requestUrl = Strings::replace($requestUrl, $this->urlFilters['url']);
$tmp = explode('?', $requestUrl, 2);
$url->setPath(Strings::replace($tmp[0], $this->urlFilters['path']));
$url->setPath(Strings::fixEncoding(Strings::replace($tmp[0], $this->urlFilters['path'])));
$url->setQuery(isset($tmp[1]) ? $tmp[1] : '');

// normalized url
$url->canonicalize();
$url->setPath(Strings::fixEncoding($url->getPath()));

// detect script path
if (isset($_SERVER['SCRIPT_NAME'])) {
$script = $_SERVER['SCRIPT_NAME'];
Expand Down
8 changes: 4 additions & 4 deletions tests/Http/Request.request.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ test(function() {
Assert::same( 'nette.org', $request->getUrl()->host );
Assert::same( 8080, $request->getUrl()->port );
Assert::same( '/file.php', $request->getUrl()->path );
Assert::same( "x param=val.&pa%\x72am=val2&param3=v a%26l%3Du%2Be", $request->getUrl()->query );
Assert::same( 'x param=val.&pa%%72am=val2&param3=v%20a%26l%3Du%2Be', $request->getUrl()->query );
Assert::same( '', $request->getUrl()->fragment );
Assert::same( 'val.', $request->getQuery('x_param') );
Assert::same( 'val2', $request->getQuery('pa%ram') );
Assert::same( 'nette.org:8080', $request->getUrl()->authority );
Assert::same( 'https://nette.org:8080', $request->getUrl()->hostUrl );
Assert::same( 'https://nette.org:8080/', $request->getUrl()->baseUrl );
Assert::same( '/', $request->getUrl()->basePath );
Assert::same( "file.php?x param=val.&pa%\x72am=val2&param3=v a%26l%3Du%2Be", $request->getUrl()->relativeUrl );
Assert::same( "https://nette.org:8080/file.php?x param=val.&pa%\x72am=val2&param3=v a%26l%3Du%2Be", $request->getUrl()->absoluteUrl );
Assert::same( 'file.php?x param=val.&pa%%72am=val2&param3=v%20a%26l%3Du%2Be', $request->getUrl()->relativeUrl );
Assert::same( 'https://nette.org:8080/file.php?x param=val.&pa%%72am=val2&param3=v%20a%26l%3Du%2Be', $request->getUrl()->absoluteUrl );
Assert::same( '', $request->getUrl()->pathInfo );
});

Expand All @@ -66,7 +66,7 @@ test(function() {
Assert::same( 'nette.org', $request->getUrl()->host );
Assert::same( 8080, $request->getUrl()->port );
Assert::same( '/file.php', $request->getUrl()->path );
Assert::same( 'x param=val.&pa%ram=val2&param3=v a%26l%3Du%2Be)', $request->getUrl()->query );
Assert::same( 'x param=val.&pa%%72am=val2&param3=v%20a%26l%3Du%2Be)', $request->getUrl()->query );
Assert::same( '', $request->getUrl()->fragment );
Assert::same( 'val.', $request->getQuery('x_param') );
Assert::same( 'val2', $request->getQuery('pa%ram') );
Expand Down

0 comments on commit 5fe8503

Please sign in to comment.