Skip to content

Commit f754173

Browse files
authored
Remove future.v7_relativeSplatPath flag (#11695)
1 parent 05a94ec commit f754173

File tree

18 files changed

+185
-271
lines changed

18 files changed

+185
-271
lines changed

.changeset/tidy-clouds-lay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": major
3+
---
4+
5+
Remove `v7_relativeSplatPath` future flag

integration/form-test.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ test.describe("Forms", () => {
589589
await app.goto("/inbox");
590590
let html = await app.getHtml();
591591
let el = getElement(html, `#${STATIC_ROUTE_NO_ACTION}`);
592-
expect(el.attr("action")).toMatch("/inbox");
592+
expect(el.attr("action")).toBe("/inbox");
593593
});
594594

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

11281128
expect(await app.getHtml()).toMatch("Submitted - No");
11291129
// This submission should ignore the index route and the pathless layout

packages/react-router/__tests__/dom/data-browser-router-test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,7 @@ function testDomRouter(
29552955
let { container } = render(<RouterProvider router={router} />);
29562956

29572957
expect(container.querySelector("form")?.getAttribute("action")).toBe(
2958-
"/foo?a=1"
2958+
"/foo/bar?a=1"
29592959
);
29602960
});
29612961

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

29772977
expect(container.querySelector("form")?.getAttribute("action")).toBe(
2978-
"/foo"
2978+
"/foo/bar"
29792979
);
29802980
});
29812981

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

29972997
expect(container.querySelector("form")?.getAttribute("action")).toBe(
2998-
"/foo"
2998+
"/foo/bar"
29992999
);
30003000
});
30013001
});
@@ -3129,7 +3129,7 @@ function testDomRouter(
31293129
let { container } = render(<RouterProvider router={router} />);
31303130

31313131
expect(container.querySelector("form")?.getAttribute("action")).toBe(
3132-
"/inbox"
3132+
"/inbox/messages/1/2"
31333133
);
31343134
});
31353135
});

packages/react-router/__tests__/dom/link-href-test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ describe("<Link> href", () => {
530530
});
531531

532532
expect(renderer.root.findByType("a").props.href).toEqual(
533-
"/inbox/messages"
533+
"/inbox/messages/abc"
534534
);
535535
});
536536

packages/react-router/__tests__/dom/special-characters-test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,13 @@ describe("special character tests", () => {
581581
}
582582

583583
function Child() {
584+
let location = useLocation();
585+
let to = location.pathname.endsWith("grandchild")
586+
? "."
587+
: "./grandchild";
584588
return (
585589
<>
586-
<Link to="./grandchild">Link to grandchild</Link>
590+
<Link to={to}>Link to grandchild</Link>
587591
<Routes>
588592
<Route path="grandchild" element={<Grandchild />} />
589593
</Routes>

packages/react-router/__tests__/router/path-resolution-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ describe("path resolution", () => {
138138
path: "*",
139139
},
140140
],
141-
"/foo",
141+
"/foo/bar",
142142
false
143143
);
144144
});

0 commit comments

Comments
 (0)