Pagination Object Gives Double Slashes Going From Page 1 to Page 2

When paginating content, the nextPageURL() for Page 2 (when requested while on the 1st page) has doubles slashes before the page: portion. I would expect it to have only 1 slash (which is what all other pages have).

I would expect the search//page to simply be search/page.

For example, the Kirby website exhibits the same problem that I’m having on my site.

Search | Kirby CMS

The link for Page 2, is:

Search | Kirby CMS

But then Page 3 looks normal.

Search | Kirby CMS

And going back to Page 2 (from 3) looks normal.

Search | Kirby CMS

It’s unclear to me why, specifically, going from Page 1 to Page 2 would cause this issue. Is this a bug?

On the getirby.com site, it only happens on the search page, though, not on the showcase or blog pages. It definitely does not look right.

I wonder if this has to do with the query syntax. Do you experience this issue with all paginated pages?

Maybe its 2 things working together? If you are forcing slashes on the end of URLS via .htaccess for SEO purposes (ie to eliminate duplicate content) and if the pagination always prepends a slash, you are going to end up with two I guess.

Are you doing anything like that? Strange that it doesn’t happen when you move back and forth though.

I only have one type of paginated page (site-wide search) at the moment.

My controller for search.php resembles:

$haystack = $site->index()->filter(function($p) use ($ignoreURIs, $ignoreTemplates) {
    
    return /* conditional statements here */ true;
});

$resultsPerPage = $page->resultsPerPage()->int() ?: 10;

$searchQuery = get('q');
$results = $haystack->search($searchQuery);
$results = $results->paginate($resultsPerPage);

$pagination = $results->pagination();

The usage in the template is basically boilerplate usage.

In regards to @jimbobrjames concerns: my site doesn’t append slashes at the end of the URLs (nor does it actively try to strip slashes).

One more question: Did this issue only occur after updating? If so, with what version?

I did a quick test in a 2.5.7 Starterkit and the issue seems to appear only in combination with query parameters.

Unfortunately, not sure. I only added pagination today, so I had already upgraded to 2.5.7 before even experimenting.

Does not seem to happen with 2.5.6, only 2.5.7.

I created an issue on GitHub:
https://github.com/getkirby/kirby/issues/620