File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,8 @@ export const ComponentView: React.FC<ComponentViewProps> = ({
151
151
) ;
152
152
} ;
153
153
154
+ const srcAttributeRegex = / s r c \s * = \s * " (?< URI > \/ s t a t i c .+ ) " / gm;
155
+
154
156
const CodeView = ( { component } : { component : ImportedComponent } ) => {
155
157
const [ selectedCodeVariant , setSelectedCodeVariant ] =
156
158
React . useState < CodeVariant > ( "html" ) ;
@@ -176,7 +178,12 @@ const CodeView = ({ component }: { component: ImportedComponent }) => {
176
178
177
179
let code = "" ;
178
180
if ( selectedCodeVariant in component . code ) {
179
- code = component . code [ selectedCodeVariant ] ?? "" ;
181
+ // Resets the regex so that it doesn't break in subsequent runs
182
+ srcAttributeRegex . lastIndex = 0 ;
183
+ code = ( component . code [ selectedCodeVariant ] ?? "" ) . replaceAll (
184
+ srcAttributeRegex ,
185
+ ( _match , uri ) => `src="https://react.email${ uri } "` ,
186
+ ) ;
180
187
} else {
181
188
throw new Error ( "The code variant selected is not available" , {
182
189
cause : {
You can’t perform that action at this time.
0 commit comments