Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Decode HTML entities when formatting Store API error messages #5870

Merged
merged 6 commits into from
Apr 11, 2022
14 changes: 7 additions & 7 deletions assets/js/base/utils/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/html-entities';

/**
* Given a JS error or a fetch response error, parse and format it so it can be displayed to the user.
Expand Down Expand Up @@ -48,11 +49,10 @@ export const formatStoreApiErrorMessage = ( response ) => {
}
}

return (
response?.message ||
__(
'Something went wrong. Please contact us to get assistance.',
'woo-gutenberg-products-block'
)
);
return response?.message
? decodeEntities( response.message )
: __(
'Something went wrong. Please contact us to get assistance.',
'woo-gutenberg-products-block'
);
};