Skip to content

Commit

Permalink
fix(PageService): Fix page link for index pages
Browse files Browse the repository at this point in the history
Fixes: #1490

Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Nov 6, 2024
1 parent 8745754 commit 163d170
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Service/PageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ public function delete(int $collectiveId, int $id, string $userId): void {
public function getPageLink(string $collectiveName, PageInfo $pageInfo, bool $withFileId = true): string {
$collectiveRoute = rawurlencode($collectiveName);
$pagePathRoute = implode('/', array_map('rawurlencode', explode('/', $pageInfo->getFilePath())));
$pageTitleRoute = rawurlencode($pageInfo->getTitle());
$pageTitleRoute = ($pageInfo->getFileName() === PageInfo::INDEX_PAGE_TITLE . PageInfo::SUFFIX) ? '' : rawurlencode($pageInfo->getTitle());
$fullRoute = implode('/', array_filter([
$collectiveRoute,
$pagePathRoute,
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Service/PageServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ public function testGetPagesFromFolder(): void {

public function testGetPageLink(): void {
$collectiveName = 'My Collective';

$pageInfo1 = new PageInfo();
$pageInfo1->setId(123);
$pageInfo1->setFilePath('page one');
Expand All @@ -264,7 +265,7 @@ public function testGetPageLink(): void {

$pageInfo2 = new PageInfo();
$pageInfo2->setId(124);
$pageInfo2->setFilePath('page two/with another layer/and#spec!al_ch@rs?;');
$pageInfo2->setFilePath('page two/with another layer/and#spec!al_ch@rs?;/page');
$pageInfo2->setFileName('Readme.md');
$pageInfo2->setTitle('page');

Expand Down

0 comments on commit 163d170

Please sign in to comment.