Skip to content

Fix Category widget URLs

The category widget template expects a URL without any query params, as it appends /?cat=<selected category> to the base URL passed to it.

The Widget code tried to preserve any query param passed to it except for the cat query param. When passed to the template, this caused the invalid URLs to be generated.

Example input url:

https://example.com/channel/user?f=&tag=pasta

The URL generated for the "Dinner" category would then be:

https://example.com/channel/user&tag=pasta&tag=pasta/?cat=Dinner

Which is troublesome in more than one way, and cause at least some search bots to go wild by sending requests with increasingly long URLs.

This patch will simply discard the existing query params in the URL, so with the same input url, the generated URL for the "Dinner" category will now be:

https://example.com/channel/user/?cat=Dinner

This is comparable to what the Category Cloud and Tag Cloud widgets already do.

Merge request reports