File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed
dotcom-rendering/src/components Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import type { ArticleFormat } from '../lib/articleFormat';
1111import { palette } from '../palette' ;
1212import { Picture } from './Picture' ;
1313import { ProductLinkButton } from './ProductLinkButton' ;
14+ import { stripHtmlFromString } from './TextBlockComponent' ;
1415
1516export type Statistics = {
1617 name : string ;
@@ -101,8 +102,6 @@ const ProductInfoContainer = ({ children }: { children: ReactNode }) => (
101102 < div css = { productInfoContainer } > { children } </ div >
102103) ;
103104
104- const stripHtml = ( html : string ) => html . replace ( / < [ ^ > ] + > / g, '' ) ;
105-
106105export const InlineProductCard = ( {
107106 format,
108107 brandName,
@@ -136,7 +135,7 @@ export const InlineProductCard = ({
136135 </ ProductInfoContainer >
137136 < ButtonContainer >
138137 < ProductLinkButton
139- label = { stripHtml ( primaryCTA ) }
138+ label = { stripHtmlFromString ( primaryCTA ) }
140139 url = { primaryUrl }
141140 cssOverrides = { css `
142141 width: 100%;
@@ -147,7 +146,7 @@ export const InlineProductCard = ({
147146 cssOverrides = { css `
148147 width: 100%;
149148 ` }
150- label = { stripHtml ( secondaryCTA ) }
149+ label = { stripHtmlFromString ( secondaryCTA ) }
151150 url = { secondaryUrl }
152151 priority = { 'tertiary' }
153152 />
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ const isOpenQuote = (t: string): boolean => {
4343 ] . includes ( t ) ;
4444} ;
4545
46- const stripHtmlFromString = ( html : string ) : string => {
46+ export const stripHtmlFromString = ( html : string ) : string => {
4747 // https://stackoverflow.com/questions/822452/strip-html-from-text-javascript is
4848 // a good discussion on how this can be done. Of the two approaches, regex and
4949 // DOM, both have unikely failure scenarios but the impact for failure with DOM
You can’t perform that action at this time.
0 commit comments