1+ import {
2+ test ,
3+ expect ,
4+ } from "@playwright/test" ;
5+ import getPort from "get-port" ;
6+
7+ import { implementations , js , setupRscTest , validateRSCHtml } from "./rsc/utils" ;
8+
9+ implementations . forEach ( ( implementation ) => {
10+ test . describe ( `RSC Double Slashes Fix (${ implementation . name } )` , ( ) => {
11+ test . describe ( "Production" , ( ) => {
12+ let port : number ;
13+ let stopAfterAll : ( ) => void ;
14+
15+ test . afterAll ( ( ) => {
16+ stopAfterAll ?.( ) ;
17+ } ) ;
18+
19+ test . beforeAll ( async ( ) => {
20+ port = await getPort ( ) ;
21+ stopAfterAll = await setupRscTest ( {
22+ implementation,
23+ port,
24+ files : {
25+ "src/routes.ts" : js `
26+ import type { unstable_RSCRouteConfig as RSCRouteConfig } from "react-router";
27+
28+ export const routes = [
29+ {
30+ id: "root",
31+ path: "",
32+ lazy: () => import("./routes/root"),
33+ children: [
34+ {
35+ id: "double-slash-test",
36+ path: "en/test2/test",
37+ lazy: () => import("./routes/double-slash-test/home"),
38+ },
39+ ],
40+ },
41+ ] satisfies RSCRouteConfig;
42+ ` ,
43+
44+ "src/routes/double-slash-test/home.tsx" : js `
45+ export function loader() {
46+ return { message: "Double slash test successful" };
47+ }
48+
49+ export default function HomeRoute({ loaderData }) {
50+ return (
51+ <div>
52+ <h2 data-test-result>Double Slash Test</h2>
53+ <p data-test-message>{loaderData.message}</p>
54+ </div>
55+ );
56+ }
57+ ` ,
58+ } ,
59+ } ) ;
60+ } ) ;
61+
62+ test ( "should handle URLs with double slashes correctly" , async ( { page } ) => {
63+ // Test the problematic URL pattern from the issue
64+ await page . goto ( `http://localhost:${ port } //en//test2/test` ) ;
65+
66+ // Should successfully load the page despite double slashes
67+ await page . waitForSelector ( "[data-test-result]" ) ;
68+ expect ( await page . locator ( "[data-test-result]" ) . textContent ( ) ) . toBe (
69+ "Double Slash Test" ,
70+ ) ;
71+ expect ( await page . locator ( "[data-test-message]" ) . textContent ( ) ) . toBe (
72+ "Double slash test successful" ,
73+ ) ;
74+
75+ // Ensure this is using RSC
76+ validateRSCHtml ( await page . content ( ) ) ;
77+ } ) ;
78+
79+ test ( "should normalize URLs and not cause manifest loading errors" , async ( { page } ) => {
80+ // Monitor network requests to ensure no ERR_NAME_NOT_RESOLVED errors
81+ const failedRequests : string [ ] = [ ] ;
82+
83+ page . on ( 'requestfailed' , ( request ) => {
84+ failedRequests . push ( request . url ( ) ) ;
85+ } ) ;
86+
87+ // Navigate to a URL with double slashes
88+ await page . goto ( `http://localhost:${ port } //en//test2/test` ) ;
89+
90+ // Wait for the page to load
91+ await page . waitForSelector ( "[data-test-result]" ) ;
92+
93+ // Check that no manifest requests failed with name resolution errors
94+ const manifestFailures = failedRequests . filter ( url =>
95+ url . includes ( '.manifest' ) && url . includes ( '//' )
96+ ) ;
97+
98+ expect ( manifestFailures ) . toHaveLength ( 0 ) ;
99+
100+ // Ensure this is using RSC
101+ validateRSCHtml ( await page . content ( ) ) ;
102+ } ) ;
103+ } ) ;
104+ } ) ;
105+ } ) ;
0 commit comments