# FacetedSearch not working with special character

**URL:** <https://forum.litium.com/t/facetedsearch-not-working-with-special-character/1075>\
**Category:** Questions\
**Tags:** accelerator, litium-7\
**Created:** [September 5, 2019, 1:31pm UTC](https://forum.litium.com/t/facetedsearch-not-working-with-special-character/1075 "2019-09-05T13:31:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gonzalo](https://avatars.discourse-cdn.com/v4/letter/g/4bbf92/32.png) [@Gonzalo](https://forum.litium.com/u/Gonzalo)\
**Post date:** [September 5, 2019, 1:31pm UTC](https://forum.litium.com/t/facetedsearch-not-working-with-special-character/1075/1 "2019-09-05T13:31:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [September 5, 2019, 2:20pm UTC](https://forum.litium.com/t/facetedsearch-not-working-with-special-character/1075/2 "2019-09-05T14:20:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [September 6, 2019, 7:16am UTC](https://forum.litium.com/t/facetedsearch-not-working-with-special-character/1075/3 "2019-09-06T07:16:29Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![Gonzalo](https://avatars.discourse-cdn.com/v4/letter/g/4bbf92/32.png) [@Gonzalo](https://forum.litium.com/u/Gonzalo)\
**Post date:** [September 6, 2019, 1:48pm UTC](https://forum.litium.com/t/facetedsearch-not-working-with-special-character/1075/4 "2019-09-06T13:48:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [September 8, 2019, 10:00am UTC](https://forum.litium.com/t/facetedsearch-not-working-with-special-character/1075/5 "2019-09-08T10:00:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [October 6, 2019, 10:00am UTC](https://forum.litium.com/t/facetedsearch-not-working-with-special-character/1075/6 "2019-10-06T10:00:45Z")

</div>

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