URL gets updated with base path when using facets

Created on 15 January 2025, 3 months ago

When clicking on a checkbox facets the url gets updated like this:
/base-path?/base-path?f[0]=content-type%3Aarticle

The expected url is this:
/base-path?f[0]=content-type%3Aarticle

And it keeps attaching it when clicking more checkboxes since it will be part of the updated base patch in the facets link.

This happens on Drupal 11.1 in combination with facets 2.0.9 and views ajax history 1.8. It does not happen on a different site with a similar setup so maybe its specific for this project.

For some reason in our case when clicking a facet we end up in the Drupal.Ajax.prototype.beforeSerialize function. In this function it does not check if a URL has more than just query params. It just passes in the href as is:

let params = new URLSearchParams($(element).attr('href'));

In the attached patch there is an extra check that passes in everything after the "?" so the base path does not get attached. Even if I only have the problem in this specific project it would not hurt doing this extra check anyway to avoid different issue's in the future with other links.

πŸ› Bug report
Status

Active

Version

1.8

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands mike.vindicate

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024