File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
src/Illuminate/Foundation Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -575,17 +575,22 @@ public function reactRefresh()
575
575
return ;
576
576
}
577
577
578
+ $ attributes = $ this ->parseAttributes ([
579
+ 'nonce ' => $ this ->cspNonce ()
580
+ ]);
581
+
578
582
return new HtmlString (
579
583
sprintf (
580
584
<<<'HTML'
581
- <script type="module">
585
+ <script type="module" %s >
582
586
import RefreshRuntime from '%s'
583
587
RefreshRuntime.injectIntoGlobalHook(window)
584
588
window.$RefreshReg$ = () => {}
585
589
window.$RefreshSig$ = () => (type) => type
586
590
window.__vite_plugin_react_preamble_installed__ = true
587
591
</script>
588
592
HTML,
593
+ implode (' ' , $ attributes ),
589
594
$ this ->hotAsset ('@react-refresh ' )
590
595
)
591
596
);
Original file line number Diff line number Diff line change @@ -170,6 +170,25 @@ public function testItCanSpecifyCspNonceWithManifest()
170
170
);
171
171
}
172
172
173
+ public function testReactRefreshWithNoNonce ()
174
+ {
175
+ $ this ->makeViteHotFile ();
176
+
177
+ $ result = app (Vite::class)->reactRefresh ();
178
+
179
+ $ this ->assertStringNotContainsString ('nonce ' , $ result );
180
+ }
181
+
182
+ public function testReactRefreshNonce ()
183
+ {
184
+ $ this ->makeViteHotFile ();
185
+
186
+ $ nonce = ViteFacade::useCspNonce ('expected-nonce ' );
187
+ $ result = app (Vite::class)->reactRefresh ();
188
+
189
+ $ this ->assertStringContainsString (sprintf ('nonce="%s" ' , $ nonce ), $ result );
190
+ }
191
+
173
192
public function testItCanInjectIntegrityWhenPresentInManifest ()
174
193
{
175
194
$ buildDir = Str::random ();
You can’t perform that action at this time.
0 commit comments