Skip to content

Commit

Permalink
[NestedNode] Fix generation of url with special characters like '+'
Browse files Browse the repository at this point in the history
  • Loading branch information
fkroockmann committed Aug 3, 2015
1 parent 9271b3f commit 7d772df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions NestedNode/Tests/PageUrlRewritingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ public function testGenerateUniqueUrl()
$this->assertEquals('/backbee-2', $this->generatePage('backbee', null, true)->getUrl());
}

public function testGenerateUniqueUrlWithSpecialCharacters()
{
$this->assertEquals('/backbee+', $this->generatePage('backbee+', null, true)->getUrl());
$this->assertEquals('/backbee+-1', $this->generatePage('backbee+', null, true)->getUrl());
}

public function testReplaceOldDeletedUrl()
{
$this->assertTrue($this->urlGenerator->isPreserveUnicity());
Expand Down
2 changes: 1 addition & 1 deletion Rewriting/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function getUniqueness(Page $page, $url)
$existings = $this->application->getEntityManager()->getConnection()->executeQuery(
'SELECT p.uid FROM page p LEFT JOIN section s ON s.uid = p.section_uid WHERE s.root_uid = :root AND p.url REGEXP :regex',
[
'regex' => $url.'(-[0-9]+)?$',
'regex' => str_replace(['+'], ['[+]'], $url).'(-[0-9]+)?$',
'root' => $page->getRoot()->getUid(),
]
)->fetchAll();
Expand Down

0 comments on commit 7d772df

Please sign in to comment.