Skip to content

Commit 225916b

Browse files
authored
Fix splat route index matching (#6130)
1 parent c691ae1 commit 225916b

File tree

4 files changed

+110
-4
lines changed

4 files changed

+110
-4
lines changed

integration/revalidate-test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ test.describe("Revalidation", () => {
4444
}
4545
`,
4646

47+
"app/routes/_index.jsx": js`
48+
export default function Component() {
49+
return <h1>Index</h1>;
50+
}
51+
`,
4752
"app/routes/parent.jsx": js`
4853
import { json } from "@remix-run/node";
4954
import { Outlet, useLoaderData } from "@remix-run/react";

integration/splat-routes-test.ts

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { test, expect } from "@playwright/test";
33
import { createFixture, js } from "./helpers/create-fixture";
44
import type { Fixture } from "./helpers/create-fixture";
55

6-
test.describe("rendering", () => {
7-
let fixture: Fixture;
6+
let fixture: Fixture;
87

8+
test.describe("rendering", () => {
99
let ROOT_$ = "FLAT";
1010
let ROOT_INDEX = "ROOT_INDEX";
1111
let FLAT_$ = "FLAT";
@@ -128,3 +128,105 @@ test.describe("rendering", () => {
128128
expect(await res.text()).toMatch(PARENTLESS_$);
129129
});
130130
});
131+
132+
test.describe("root splat route without index", () => {
133+
test("matches routes correctly (v1)", async ({ page }) => {
134+
fixture = await createFixture({
135+
future: { v2_routeConvention: false },
136+
files: {
137+
"app/routes/$.jsx": js`
138+
export default function Component() {
139+
return <h1>Hello Splat</h1>
140+
}
141+
`,
142+
},
143+
});
144+
145+
let res = await fixture.requestDocument("/");
146+
expect(await res.text()).toMatch("Hello Splat");
147+
148+
res = await fixture.requestDocument("/splat");
149+
expect(await res.text()).toMatch("Hello Splat");
150+
151+
res = await fixture.requestDocument("/splat/deep/path");
152+
expect(await res.text()).toMatch("Hello Splat");
153+
});
154+
155+
test("matches routes correctly (v2)", async ({ page }) => {
156+
fixture = await createFixture({
157+
future: { v2_routeConvention: true },
158+
files: {
159+
"app/routes/$.jsx": js`
160+
export default function Component() {
161+
return <h1>Hello Splat</h1>
162+
}
163+
`,
164+
},
165+
});
166+
167+
let res = await fixture.requestDocument("/");
168+
expect(await res.text()).toMatch("Hello Splat");
169+
170+
res = await fixture.requestDocument("/splat");
171+
expect(await res.text()).toMatch("Hello Splat");
172+
173+
res = await fixture.requestDocument("/splat/deep/path");
174+
expect(await res.text()).toMatch("Hello Splat");
175+
});
176+
});
177+
178+
test.describe("root splat route with index", () => {
179+
test("matches routes correctly (v1)", async ({ page }) => {
180+
fixture = await createFixture({
181+
future: { v2_routeConvention: false },
182+
files: {
183+
"app/routes/index.jsx": js`
184+
export default function Component() {
185+
return <h1>Hello Index</h1>
186+
}
187+
`,
188+
"app/routes/$.jsx": js`
189+
export default function Component() {
190+
return <h1>Hello Splat</h1>
191+
}
192+
`,
193+
},
194+
});
195+
196+
let res = await fixture.requestDocument("/");
197+
expect(await res.text()).toMatch("Hello Index");
198+
199+
res = await fixture.requestDocument("/splat");
200+
expect(await res.text()).toMatch("Hello Splat");
201+
202+
res = await fixture.requestDocument("/splat/deep/path");
203+
expect(await res.text()).toMatch("Hello Splat");
204+
});
205+
206+
test("matches routes correctly (v2)", async ({ page }) => {
207+
fixture = await createFixture({
208+
future: { v2_routeConvention: true },
209+
files: {
210+
"app/routes/_index.jsx": js`
211+
export default function Component() {
212+
return <h1>Hello Index</h1>
213+
}
214+
`,
215+
"app/routes/$.jsx": js`
216+
export default function Component() {
217+
return <h1>Hello Splat</h1>
218+
}
219+
`,
220+
},
221+
});
222+
223+
let res = await fixture.requestDocument("/");
224+
expect(await res.text()).toMatch("Hello Index");
225+
226+
res = await fixture.requestDocument("/splat");
227+
expect(await res.text()).toMatch("Hello Splat");
228+
229+
res = await fixture.requestDocument("/splat/deep/path");
230+
expect(await res.text()).toMatch("Hello Splat");
231+
});
232+
});

packages/remix-dev/__tests__/readConfig-test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ describe("readConfig", () => {
6868
"root": Object {
6969
"file": "root.tsx",
7070
"id": "root",
71-
"path": "",
7271
},
7372
},
7473
"serverBuildPath": Any<String>,

packages/remix-dev/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ export async function readConfig(
672672
}
673673

674674
let routes: RouteManifest = {
675-
root: { path: "", id: "root", file: rootRouteFile },
675+
root: { id: "root", file: rootRouteFile },
676676
};
677677

678678
let routesConvention: typeof flatRoutes;

0 commit comments

Comments
 (0)