Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove future.v7_relativeSplatPath flag #11695

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tidy-clouds-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-router": major
---

Remove `v7_relativeSplatPath` future flag
72 changes: 36 additions & 36 deletions integration/form-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ test.describe("Forms", () => {
await app.goto("/inbox");
let html = await app.getHtml();
let el = getElement(html, `#${STATIC_ROUTE_NO_ACTION}`);
expect(el.attr("action")).toMatch("/inbox");
expect(el.attr("action")).toBe("/inbox");
});

test("no action resolves to URL including search params", async ({
Expand All @@ -599,7 +599,7 @@ test.describe("Forms", () => {
await app.goto("/inbox?foo=bar");
let html = await app.getHtml();
let el = getElement(html, `#${STATIC_ROUTE_NO_ACTION}`);
expect(el.attr("action")).toMatch("/inbox?foo=bar");
expect(el.attr("action")).toBe("/inbox?foo=bar");
});

test("absolute action resolves relative to the root route", async ({
Expand All @@ -609,7 +609,7 @@ test.describe("Forms", () => {
await app.goto("/inbox");
let html = await app.getHtml();
let el = getElement(html, `#${STATIC_ROUTE_ABSOLUTE_ACTION}`);
expect(el.attr("action")).toMatch("/about");
expect(el.attr("action")).toBe("/about");
});

test("'.' action resolves relative to the closest route", async ({
Expand All @@ -619,15 +619,15 @@ test.describe("Forms", () => {
await app.goto("/inbox");
let html = await app.getHtml();
let el = getElement(html, `#${STATIC_ROUTE_CURRENT_ACTION}`);
expect(el.attr("action")).toMatch("/inbox");
expect(el.attr("action")).toBe("/inbox");
});

test("'.' excludes search params", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);
await app.goto("/inbox?foo=bar");
let html = await app.getHtml();
let el = getElement(html, `#${STATIC_ROUTE_CURRENT_ACTION}`);
expect(el.attr("action")).toMatch("/inbox");
expect(el.attr("action")).toBe("/inbox");
});

test("'..' action resolves relative to the parent route", async ({
Expand All @@ -637,7 +637,7 @@ test.describe("Forms", () => {
await app.goto("/inbox");
let html = await app.getHtml();
let el = getElement(html, `#${STATIC_ROUTE_PARENT_ACTION}`);
expect(el.attr("action")).toMatch("/");
expect(el.attr("action")).toBe("/");
});

test("'..' action with more .. segments than parent routes resolves relative to the root route", async ({
Expand All @@ -647,7 +647,7 @@ test.describe("Forms", () => {
await app.goto("/inbox");
let html = await app.getHtml();
let el = getElement(html, `#${STATIC_ROUTE_TOO_MANY_DOTS_ACTION}`);
expect(el.attr("action")).toMatch("/");
expect(el.attr("action")).toBe("/about");
});
});

Expand All @@ -659,7 +659,7 @@ test.describe("Forms", () => {
await app.goto("/blog/abc");
let html = await app.getHtml();
let el = getElement(html, `#${DYNAMIC_ROUTE_NO_ACTION}`);
expect(el.attr("action")).toMatch("/blog/abc");
expect(el.attr("action")).toBe("/blog/abc");
});

test("no action resolves to URL including search params", async ({
Expand All @@ -669,7 +669,7 @@ test.describe("Forms", () => {
await app.goto("/blog/abc?foo=bar");
let html = await app.getHtml();
let el = getElement(html, `#${DYNAMIC_ROUTE_NO_ACTION}`);
expect(el.attr("action")).toMatch("/blog/abc?foo=bar");
expect(el.attr("action")).toBe("/blog/abc?foo=bar");
});

test("absolute action resolves relative to the root route", async ({
Expand All @@ -679,7 +679,7 @@ test.describe("Forms", () => {
await app.goto("/blog/abc");
let html = await app.getHtml();
let el = getElement(html, `#${DYNAMIC_ROUTE_ABSOLUTE_ACTION}`);
expect(el.attr("action")).toMatch("/about");
expect(el.attr("action")).toBe("/about");
});

test("'.' action resolves relative to the closest route", async ({
Expand All @@ -689,15 +689,15 @@ test.describe("Forms", () => {
await app.goto("/blog/abc");
let html = await app.getHtml();
let el = getElement(html, `#${DYNAMIC_ROUTE_CURRENT_ACTION}`);
expect(el.attr("action")).toMatch("/blog/abc");
expect(el.attr("action")).toBe("/blog/abc");
});

test("'.' excludes search params", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);
await app.goto("/blog/abc?foo=bar");
let html = await app.getHtml();
let el = getElement(html, `#${DYNAMIC_ROUTE_CURRENT_ACTION}`);
expect(el.attr("action")).toMatch("/blog/abc");
expect(el.attr("action")).toBe("/blog/abc");
});

test("'..' action resolves relative to the parent route", async ({
Expand All @@ -707,7 +707,7 @@ test.describe("Forms", () => {
await app.goto("/blog/abc");
let html = await app.getHtml();
let el = getElement(html, `#${DYNAMIC_ROUTE_PARENT_ACTION}`);
expect(el.attr("action")).toMatch("/blog");
expect(el.attr("action")).toBe("/blog");
});

test("'..' action with more .. segments than parent routes resolves relative to the root route", async ({
Expand All @@ -717,7 +717,7 @@ test.describe("Forms", () => {
await app.goto("/blog/abc");
let html = await app.getHtml();
let el = getElement(html, `#${DYNAMIC_ROUTE_TOO_MANY_DOTS_ACTION}`);
expect(el.attr("action")).toMatch("/");
expect(el.attr("action")).toBe("/about");
});
});

Expand All @@ -729,7 +729,7 @@ test.describe("Forms", () => {
await app.goto("/blog");
let html = await app.getHtml();
let el = getElement(html, `#${INDEX_ROUTE_NO_ACTION}`);
expect(el.attr("action")).toMatch("/blog");
expect(el.attr("action")).toBe("/blog?index");
});

test("no action resolves to URL including search params", async ({
Expand All @@ -739,7 +739,7 @@ test.describe("Forms", () => {
await app.goto("/blog?foo=bar");
let html = await app.getHtml();
let el = getElement(html, `#${INDEX_ROUTE_NO_ACTION}`);
expect(el.attr("action")).toMatch("/blog?index&foo=bar");
expect(el.attr("action")).toBe("/blog?index&foo=bar");
});

test("absolute action resolves relative to the root route", async ({
Expand All @@ -749,7 +749,7 @@ test.describe("Forms", () => {
await app.goto("/blog");
let html = await app.getHtml();
let el = getElement(html, `#${INDEX_ROUTE_ABSOLUTE_ACTION}`);
expect(el.attr("action")).toMatch("/about");
expect(el.attr("action")).toBe("/about");
});

test("'.' action resolves relative to the closest route", async ({
Expand All @@ -759,15 +759,15 @@ test.describe("Forms", () => {
await app.goto("/blog");
let html = await app.getHtml();
let el = getElement(html, `#${INDEX_ROUTE_CURRENT_ACTION}`);
expect(el.attr("action")).toMatch("/blog");
expect(el.attr("action")).toBe("/blog?index");
});

test("'.' excludes search params", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);
await app.goto("/blog?foo=bar");
let html = await app.getHtml();
let el = getElement(html, `#${INDEX_ROUTE_CURRENT_ACTION}`);
expect(el.attr("action")).toMatch("/blog");
expect(el.attr("action")).toBe("/blog?index");
});

test("'..' action resolves relative to the parent route", async ({
Expand All @@ -777,7 +777,7 @@ test.describe("Forms", () => {
await app.goto("/blog");
let html = await app.getHtml();
let el = getElement(html, `#${INDEX_ROUTE_PARENT_ACTION}`);
expect(el.attr("action")).toMatch("/");
expect(el.attr("action")).toBe("/");
});

test("'..' action with more .. segments than parent routes resolves relative to the root route", async ({
Expand All @@ -787,7 +787,7 @@ test.describe("Forms", () => {
await app.goto("/blog");
let html = await app.getHtml();
let el = getElement(html, `#${INDEX_ROUTE_TOO_MANY_DOTS_ACTION}`);
expect(el.attr("action")).toMatch("/");
expect(el.attr("action")).toBe("/about");
});

test("handles search params correctly on GET submissions", async ({
Expand Down Expand Up @@ -849,7 +849,7 @@ test.describe("Forms", () => {
await app.goto("/blog");
let html = await app.getHtml();
let el = getElement(html, `#${LAYOUT_ROUTE_NO_ACTION}`);
expect(el.attr("action")).toMatch("/blog");
expect(el.attr("action")).toBe("/blog");
});

test("no action resolves to URL including search params", async ({
Expand All @@ -859,7 +859,7 @@ test.describe("Forms", () => {
await app.goto("/blog?foo=bar");
let html = await app.getHtml();
let el = getElement(html, `#${LAYOUT_ROUTE_NO_ACTION}`);
expect(el.attr("action")).toMatch("/blog?foo=bar");
expect(el.attr("action")).toBe("/blog?foo=bar");
});

test("absolute action resolves relative to the root route", async ({
Expand All @@ -869,7 +869,7 @@ test.describe("Forms", () => {
await app.goto("/blog");
let html = await app.getHtml();
let el = getElement(html, `#${LAYOUT_ROUTE_ABSOLUTE_ACTION}`);
expect(el.attr("action")).toMatch("/about");
expect(el.attr("action")).toBe("/about");
});

test("'.' action resolves relative to the closest route", async ({
Expand All @@ -879,15 +879,15 @@ test.describe("Forms", () => {
await app.goto("/blog");
let html = await app.getHtml();
let el = getElement(html, `#${LAYOUT_ROUTE_CURRENT_ACTION}`);
expect(el.attr("action")).toMatch("/blog");
expect(el.attr("action")).toBe("/blog");
});

test("'.' excludes search params", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);
await app.goto("/blog?foo=bar");
let html = await app.getHtml();
let el = getElement(html, `#${LAYOUT_ROUTE_CURRENT_ACTION}`);
expect(el.attr("action")).toMatch("/blog");
expect(el.attr("action")).toBe("/blog");
});

test("'..' action resolves relative to the parent route", async ({
Expand All @@ -897,7 +897,7 @@ test.describe("Forms", () => {
await app.goto("/blog");
let html = await app.getHtml();
let el = getElement(html, `#${LAYOUT_ROUTE_PARENT_ACTION}`);
expect(el.attr("action")).toMatch("/");
expect(el.attr("action")).toBe("/");
});

test("'..' action with more .. segments than parent routes resolves relative to the root route", async ({
Expand All @@ -907,7 +907,7 @@ test.describe("Forms", () => {
await app.goto("/blog");
let html = await app.getHtml();
let el = getElement(html, `#${LAYOUT_ROUTE_TOO_MANY_DOTS_ACTION}`);
expect(el.attr("action")).toMatch("/");
expect(el.attr("action")).toBe("/about");
});
});

Expand All @@ -919,7 +919,7 @@ test.describe("Forms", () => {
await app.goto("/projects/blarg");
let html = await app.getHtml();
let el = getElement(html, `#${SPLAT_ROUTE_NO_ACTION}`);
expect(el.attr("action")).toMatch("/projects");
expect(el.attr("action")).toBe("/projects/blarg");
});

test("no action resolves to URL including search params", async ({
Expand All @@ -929,7 +929,7 @@ test.describe("Forms", () => {
await app.goto("/projects/blarg?foo=bar");
let html = await app.getHtml();
let el = getElement(html, `#${SPLAT_ROUTE_NO_ACTION}`);
expect(el.attr("action")).toMatch("/projects?foo=bar");
expect(el.attr("action")).toBe("/projects/blarg?foo=bar");
});

test("absolute action resolves relative to the root route", async ({
Expand All @@ -939,7 +939,7 @@ test.describe("Forms", () => {
await app.goto("/projects/blarg");
let html = await app.getHtml();
let el = getElement(html, `#${SPLAT_ROUTE_ABSOLUTE_ACTION}`);
expect(el.attr("action")).toMatch("/about");
expect(el.attr("action")).toBe("/about");
});

test("'.' action resolves relative to the closest route", async ({
Expand All @@ -949,15 +949,15 @@ test.describe("Forms", () => {
await app.goto("/projects/blarg");
let html = await app.getHtml();
let el = getElement(html, `#${SPLAT_ROUTE_CURRENT_ACTION}`);
expect(el.attr("action")).toMatch("/projects");
expect(el.attr("action")).toBe("/projects/blarg");
});

test("'.' excludes search params", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);
await app.goto("/projects/blarg?foo=bar");
let html = await app.getHtml();
let el = getElement(html, `#${SPLAT_ROUTE_CURRENT_ACTION}`);
expect(el.attr("action")).toMatch("/projects");
expect(el.attr("action")).toBe("/projects/blarg");
});

test("'..' action resolves relative to the parent route", async ({
Expand All @@ -967,7 +967,7 @@ test.describe("Forms", () => {
await app.goto("/projects/blarg");
let html = await app.getHtml();
let el = getElement(html, `#${SPLAT_ROUTE_PARENT_ACTION}`);
expect(el.attr("action")).toMatch("/projects");
expect(el.attr("action")).toBe("/projects");
});

test("'..' action with more .. segments than parent routes resolves relative to the root route", async ({
Expand All @@ -977,7 +977,7 @@ test.describe("Forms", () => {
await app.goto("/projects/blarg");
let html = await app.getHtml();
let el = getElement(html, `#${SPLAT_ROUTE_TOO_MANY_DOTS_ACTION}`);
expect(el.attr("action")).toMatch("/");
expect(el.attr("action")).toBe("/about");
});
});
});
Expand Down Expand Up @@ -1123,7 +1123,7 @@ test.describe("Forms", () => {
expect(html).toMatch("Pathless Layout Index");

let el = getElement(html, `form`);
expect(el.attr("action")).toMatch("/pathless-layout-parent");
expect(el.attr("action")).toBe("/pathless-layout-parent");

expect(await app.getHtml()).toMatch("Submitted - No");
// This submission should ignore the index route and the pathless layout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2955,7 +2955,7 @@ function testDomRouter(
let { container } = render(<RouterProvider router={router} />);

expect(container.querySelector("form")?.getAttribute("action")).toBe(
"/foo?a=1"
"/foo/bar?a=1"
);
});

Expand All @@ -2975,7 +2975,7 @@ function testDomRouter(
let { container } = render(<RouterProvider router={router} />);

expect(container.querySelector("form")?.getAttribute("action")).toBe(
"/foo"
"/foo/bar"
);
});

Expand All @@ -2995,7 +2995,7 @@ function testDomRouter(
let { container } = render(<RouterProvider router={router} />);

expect(container.querySelector("form")?.getAttribute("action")).toBe(
"/foo"
"/foo/bar"
);
});
});
Expand Down Expand Up @@ -3129,7 +3129,7 @@ function testDomRouter(
let { container } = render(<RouterProvider router={router} />);

expect(container.querySelector("form")?.getAttribute("action")).toBe(
"/inbox"
"/inbox/messages/1/2"
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/__tests__/dom/link-href-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ describe("<Link> href", () => {
});

expect(renderer.root.findByType("a").props.href).toEqual(
"/inbox/messages"
"/inbox/messages/abc"
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,13 @@ describe("special character tests", () => {
}

function Child() {
let location = useLocation();
let to = location.pathname.endsWith("grandchild")
? "."
: "./grandchild";
return (
<>
<Link to="./grandchild">Link to grandchild</Link>
<Link to={to}>Link to grandchild</Link>
<Routes>
<Route path="grandchild" element={<Grandchild />} />
</Routes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe("path resolution", () => {
path: "*",
},
],
"/foo",
"/foo/bar",
false
);
});
Expand Down
Loading