File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
content-gen/src/app/frontend/src Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -363,9 +363,12 @@ function App() {
363363 // Replace old color/product name in text_content when switching products
364364 const oldName = selectedProducts [ 0 ] ?. product_name ;
365365 const newName = mentionedProduct ?. product_name ;
366+ const nameRegex = oldName
367+ ? new RegExp ( oldName . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) , 'gi' )
368+ : undefined ;
366369 const swapName = ( s ?: string ) => {
367- if ( ! s || ! oldName || ! newName || oldName === newName ) return s ;
368- return s . replace ( new RegExp ( oldName . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g , '\\$&' ) , 'gi' ) , newName ) ;
370+ if ( ! s || ! oldName || ! newName || oldName === newName || ! nameRegex ) return s ;
371+ return s . replace ( nameRegex , ( ) => newName ) ;
369372 } ;
370373 const tc = generatedContent . text_content ;
371374
You can’t perform that action at this time.
0 commit comments