Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
* release:
  1.3.2
  • Loading branch information
tuegeb committed Oct 20, 2017
2 parents 4e7c34a + b37fe5d commit 5c795b9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 1.3.2
- Fixed handling of seo path with encoded chars

Version 1.3.1
- Completed SEO-Enhancer integration

Expand Down
4 changes: 3 additions & 1 deletion src/FACTFinder/Core/Client/RequestParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ public function getClientRequestParameters()
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$seoPathPosition = strrpos($path, "/s/");
if ($seoPathPosition > -1) {
$parameters['seoPath'] = substr($path, $seoPathPosition + 2);
$encodedSeoPath = substr($path, $seoPathPosition + 2);
$decodedSeoPath = urldecode($encodedSeoPath);
$parameters['seoPath'] = $decodedSeoPath;
}
}

Expand Down
13 changes: 13 additions & 0 deletions tests/Core/Client/RequestParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,17 @@ public function testRequestTargetEncoding()
$this->assertEquals("/ind\xC3\xA4x.php", $this->requestParser
->getRequestTarget());
}

function testSeoParameterConversion()
{
$_SERVER['REQUEST_URI'] = '/s/a%20b';

$expectedParameters = array(
'seoPath' => '/a b',
);
$actualParameters = $this->requestParser
->getClientRequestParameters()
->getArray();
$this->assertEquals($expectedParameters, $actualParameters);
}
}
34 changes: 34 additions & 0 deletions tests/Core/Client/UrlBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function testGenerateUrlFromRequestTarget()
$this->parameters['foo'] = "b\xC3\xA4r"; // UTF-8 encoded 'bär'
$this->parameters['query'] = 'bmx bike'; // maps to 'keywords' and has spaces


$actualUrl = $this->urlBuilder->generateUrl($this->parameters);

// The 'ä' gets ISO-8859-1 encoded.
Expand All @@ -57,6 +58,21 @@ public function testGenerateUrlFromRequestTarget()
);
}

public function testGenerateUrlWithSeoPathFromRequestTarget()
{
$_SERVER['REQUEST_URI'] = 'has%20spaces/index.php';

$this->parameters['format'] = 'json'; // is ignored
$this->parameters['seoPath'] = '/a b'; // less common seo path which has spaces

$actualUrl = $this->urlBuilder->generateUrl($this->parameters);

$this->assertEquals(
'has spaces/index.php/s/a b?',
$actualUrl
);
}

public function testGenerateUrlFromExplicitTarget()
{
$_SERVER['REQUEST_URI'] = '/index.php';
Expand All @@ -78,4 +94,22 @@ public function testGenerateUrlFromExplicitTarget()
$actualUrl
);
}

public function testGenerateUrlWithSeoPathFromExplicitTarget()
{
$_SERVER['REQUEST_URI'] = 'has%20spaces/index.php';

$this->parameters['format'] = 'json'; // is ignored
$this->parameters['seoPath'] = '/a-b'; // common seo path with no spaces

$actualUrl = $this->urlBuilder->generateUrl(
$this->parameters,
'/'
);

$this->assertEquals(
'/s/a-b?',
$actualUrl
);
}
}

0 comments on commit 5c795b9

Please sign in to comment.