@@ -438,6 +438,59 @@ test.describe("Prerendering", () => {
438
438
} ) ;
439
439
} ) ;
440
440
441
+ test ( "Adds leading slashes if omitted in config" , async ( ) => {
442
+ fixture = await createFixture ( {
443
+ prerender : true ,
444
+ files : {
445
+ ...files ,
446
+ "react-router.config.ts" : js `
447
+ export default {
448
+ async prerender() {
449
+ await new Promise(r => setTimeout(r, 1));
450
+ return ['/', 'about'];
451
+ },
452
+ }
453
+ ` ,
454
+ "vite.config.ts" : js `
455
+ import { defineConfig } from "vite";
456
+ import { reactRouter } from "@react-router/dev/vite";
457
+
458
+ export default defineConfig({
459
+ build: { manifest: true },
460
+ plugins: [
461
+ reactRouter()
462
+ ],
463
+ });
464
+ ` ,
465
+ } ,
466
+ } ) ;
467
+ appFixture = await createAppFixture ( fixture ) ;
468
+
469
+ let clientDir = path . join ( fixture . projectDir , "build" , "client" ) ;
470
+ expect ( listAllFiles ( clientDir ) . sort ( ) ) . toEqual ( [
471
+ "__manifest" ,
472
+ "_root.data" ,
473
+ "about.data" ,
474
+ "about/index.html" ,
475
+ "favicon.ico" ,
476
+ "index.html" ,
477
+ ] ) ;
478
+
479
+ let res = await fixture . requestDocument ( "/" ) ;
480
+ let html = await res . text ( ) ;
481
+ expect ( html ) . toMatch ( "<title>Index Title: Index Loader Data</title>" ) ;
482
+ expect ( html ) . toMatch ( "<h1>Root</h1>" ) ;
483
+ expect ( html ) . toMatch ( '<h2 data-route="true">Index</h2>' ) ;
484
+ expect ( html ) . toMatch ( '<p data-loader-data="true">Index Loader Data</p>' ) ;
485
+
486
+ res = await fixture . requestDocument ( "/about" ) ;
487
+ html = await res . text ( ) ;
488
+ expect ( html ) . toMatch ( "<title>About Title: About Loader Data</title>" ) ;
489
+ expect ( html ) . toMatch ( "<h1>Root</h1>" ) ;
490
+ expect ( html ) . toMatch ( '<h2 data-route="true">About</h2>' ) ;
491
+ expect ( html ) . toMatch ( '<p data-loader-data="true">About Loader Data</p>' ) ;
492
+ } ) ;
493
+
441
494
test ( "Hydrates into a navigable app" , async ( { page } ) => {
442
495
fixture = await createFixture ( {
443
496
prerender : true ,
@@ -588,7 +641,7 @@ test.describe("Prerendering", () => {
588
641
"vite.config.ts" : js `
589
642
import { defineConfig } from "vite";
590
643
import { reactRouter } from "@react-router/dev/vite";
591
-
644
+
592
645
export default defineConfig({
593
646
build: { manifest: true },
594
647
plugins: [reactRouter()],
@@ -602,7 +655,7 @@ test.describe("Prerendering", () => {
602
655
data: "한글 데이터 - UTF-8 문자",
603
656
};
604
657
}
605
-
658
+
606
659
export default function Comp() {
607
660
let data = useLoaderData();
608
661
return (
@@ -622,7 +675,7 @@ test.describe("Prerendering", () => {
622
675
data: "非プリレンダリングデータ - UTF-8文字",
623
676
};
624
677
}
625
-
678
+
626
679
export default function Comp() {
627
680
let data = useLoaderData();
628
681
return (
0 commit comments