Skip to content

Commit 125fac6

Browse files
committed
Replace regex with DOMParser
1 parent 015255f commit 125fac6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

refactor/src/components/Product/SingleProduct.component.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import LoadingSpinner from '@/components/LoadingSpinner/LoadingSpinner.component
1616
*/
1717
const SingleProduct = ({ product }: any) => {
1818
const [isLoading, setIsLoading] = useState<boolean>(true);
19-
const [selectedVariation, setSelectedVariation] = useState<any>();
19+
const [selectedVariation, setSelectedVariation] = useState<string>();
2020

2121
useEffect(() => {
2222
setIsLoading(false);
@@ -41,7 +41,11 @@ const SingleProduct = ({ product }: any) => {
4141
}
4242

4343
// Strip out HTML from description
44-
const DESCRIPTION_WITHOUT_HTML = description.replace(/(<([^>]+)>)/gi, '');
44+
const DESCRIPTION_WITHOUT_HTML = new DOMParser().parseFromString(
45+
description,
46+
'text/html'
47+
).body.textContent;
48+
4549
const placeholderFallBack = 'https://via.placeholder.com/600';
4650

4751
return (

0 commit comments

Comments
 (0)