Fix: encode and decode term slug to support non-ASCII terms (https://github.com/woocommerce/woocommerce-blocks/pull/7906)

This commit is contained in:
Tung Du 2022-12-12 17:46:20 +07:00 committed by GitHub
parent 8bbb14f23b
commit e306334911
2 changed files with 10 additions and 1 deletions

View File

@ -282,6 +282,13 @@ const AttributeFilterBlock = ( {
*/
const updateFilterUrl = useCallback(
( query, allFiltersRemoved = false ) => {
query = query.map( ( item: AttributeQuery ) => ( {
...item,
slug: item.slug.map( ( slug: string ) =>
decodeURIComponent( slug )
),
} ) );
if ( allFiltersRemoved ) {
if ( ! attributeObject?.taxonomy ) {
return;

View File

@ -71,7 +71,9 @@ export const getActiveFilters = (
? defaultAttributeParam.split( ',' )
: [];
return defaultCheckedValue;
return defaultCheckedValue.map( ( value ) =>
encodeURIComponent( value ).toLowerCase()
);
}
return [];