FacetedSearch not working with special character

Hi

Having problem with filtering products
When selecting brands the url keeps adding with additional brand to the url, as showed below:

litiumdemo.local/woman?brand=saint%20tropez&brand=adrian%20hammond&brand=odd%20molly

And if the brand has special character “&” (Count & Countess), the search doesn’t work, it just keeps adding the brand to the url:

litiumdemo.local/woman?%252520countess&%2520countess&brand=count%20&%20countess

Is it a bug?
Thanks in advanced.

Litium version: 7.2

This is a bug, please report this in the Docs.

A workaround could be to change FacetedSearch.action.js and use encodeURIComponent on group.id and val in toFilterCriteria.

const toFilterCriteria = groups => groups
    .map(group => group.selectedOptions
        .filter(val => val && val.length > 0)
        .map(val => `${encodeURIComponent(group.id)}=${encodeURIComponent(val)}`)
    )
    .reduce((flat, current) => [...flat, ...current], []);

Since you encode the group.id as well, you need to decode the param in the submit function, otherwise it won’t remove the filter when you click it.

The entire query string will be encoded again in History.middleware.js though.

Thanks Nils, this is a working workaround.

We are currently working on just adding brands to brand parameter.

litiumdemo.local/woman?brand=saint%20tropez&brand=adrian%20hammond&brand=odd%20molly

so instead for code above, it would request the code below:

litiumdemo.local/woman?brand=saint%20tropez,adrian%20hammond,odd%20molly

It will be hard to detect if the comma delimiter in the brand is a delimiter between the brands or if the brand name contains a comma delimiter. I don’t think it will be possible in a good way to reorganizing the values like that.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.