From def524fcd0c686b8f705e6cddc94a1cd67f8a876 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Mon, 30 Jan 2023 18:30:07 +0200 Subject: [PATCH 1/2] Lodash: Refactor flat term selection away from _.unescape() --- packages/editor/src/utils/terms.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/utils/terms.js b/packages/editor/src/utils/terms.js index 33fe93dfa911b..c3a4c6cf812cc 100644 --- a/packages/editor/src/utils/terms.js +++ b/packages/editor/src/utils/terms.js @@ -1,7 +1,12 @@ /** * External dependencies */ -import { groupBy, unescape as lodashUnescapeString } from 'lodash'; +import { groupBy } from 'lodash'; + +/** + * WordPress dependencies + */ +import { decodeEntities } from '@wordpress/html-entities'; /** * Returns terms in a tree form. @@ -41,7 +46,7 @@ export function buildTermsTree( flatTerms ) { // Lodash unescape function handles ' but not ' which may be return in some API requests. export const unescapeString = ( arg ) => { - return lodashUnescapeString( arg.replace( ''', "'" ) ); + return decodeEntities( arg ); }; /** From 9c2d853bbfe8ea77c3daeca351c66ae62150724a Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Mon, 30 Jan 2023 18:37:53 +0200 Subject: [PATCH 2/2] Remove unnecessary comment --- packages/editor/src/utils/terms.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/editor/src/utils/terms.js b/packages/editor/src/utils/terms.js index c3a4c6cf812cc..edb0923317e0e 100644 --- a/packages/editor/src/utils/terms.js +++ b/packages/editor/src/utils/terms.js @@ -44,7 +44,6 @@ export function buildTermsTree( flatTerms ) { return fillWithChildren( termsByParent[ '0' ] || [] ); } -// Lodash unescape function handles ' but not ' which may be return in some API requests. export const unescapeString = ( arg ) => { return decodeEntities( arg ); };