Skip to content

Commit 585b075

Browse files
committed
fix: corrected URL for pagination
1 parent 2a76722 commit 585b075

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

phpmyfaq/src/phpMyFAQ/Pagination.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,16 @@ public function render(): string
277277
* @param string $url url
278278
* @param int $page page number
279279
*/
280-
protected function renderUrl(string $url, int $page): string
280+
protected function renderUrl(string $url = '', int $page = 1): string
281281
{
282-
return sprintf($this->rewriteUrl, $page);
282+
if ($url === '') {
283+
$url = sprintf($this->rewriteUrl, $page);
284+
} else {
285+
$cleanedUrl = Strings::preg_replace(['$&(amp;|)' . $this->pageParamName . '=(\d+)$'], '', $url);
286+
$url = sprintf('%s&%s=%d', $cleanedUrl, $this->pageParamName, $page);
287+
}
288+
289+
return $url;
283290
}
284291

285292
/**

0 commit comments

Comments
 (0)