From a02194bee92147f822e9c17e9b9edf0204c79852 Mon Sep 17 00:00:00 2001 From: levvysokiy Date: Thu, 19 Sep 2024 22:44:10 +0300 Subject: [PATCH 1/3] slashes encoding in generatePath params --- .idea/.gitignore | 5 +++++ .idea/inspectionProfiles/Project_Default.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/react-router.iml | 12 ++++++++++++ .idea/vcs.xml | 6 ++++++ .../react-router/__tests__/generatePath-test.tsx | 5 +++++ packages/react-router/lib/router/utils.ts | 3 +++ 7 files changed, 45 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/react-router.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000..b58b603fea --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000000..03d9549ea8 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000..d3fe982514 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/react-router.iml b/.idea/react-router.iml new file mode 100644 index 0000000000..24643cc374 --- /dev/null +++ b/.idea/react-router.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000..35eb1ddfbb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/packages/react-router/__tests__/generatePath-test.tsx b/packages/react-router/__tests__/generatePath-test.tsx index 70232f7d46..583b2ff065 100644 --- a/packages/react-router/__tests__/generatePath-test.tsx +++ b/packages/react-router/__tests__/generatePath-test.tsx @@ -58,6 +58,11 @@ describe("generatePath", () => { "/courses/baz" ); }); + it("handles slashes in dynamic params", () => { + expect(generatePath("/courses/:id", { id: "foo/bar" })).toBe( + "/courses/foo%2Fbar" + ); + }); }); describe("with extraneous params", () => { diff --git a/packages/react-router/lib/router/utils.ts b/packages/react-router/lib/router/utils.ts index f6396d2e5d..6be35b1768 100644 --- a/packages/react-router/lib/router/utils.ts +++ b/packages/react-router/lib/router/utils.ts @@ -874,6 +874,9 @@ export function generatePath( const [, key, optional] = keyMatch; let param = params[key as PathParam]; invariant(optional === "?" || param != null, `Missing ":${key}" param`); + if (typeof param === "string") { + param = param.replace(/\//g, "%2F"); + } return stringify(param); } From 6e43268515a832357957418aca3cc20f428db0dc Mon Sep 17 00:00:00 2001 From: levvysokiy Date: Thu, 19 Sep 2024 22:52:28 +0300 Subject: [PATCH 2/3] Removed the .idea folder --- .idea/.gitignore | 5 ----- .idea/inspectionProfiles/Project_Default.xml | 6 ------ .idea/modules.xml | 8 -------- .idea/react-router.iml | 12 ------------ .idea/vcs.xml | 6 ------ 5 files changed, 37 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/react-router.iml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index b58b603fea..0000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 03d9549ea8..0000000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index d3fe982514..0000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/react-router.iml b/.idea/react-router.iml deleted file mode 100644 index 24643cc374..0000000000 --- a/.idea/react-router.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddfbb..0000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 4b8bd79d75348f41a85f844f5508c8bd4839a157 Mon Sep 17 00:00:00 2001 From: levvysokiy <123007283+levvysokiy@users.noreply.github.com> Date: Thu, 19 Sep 2024 23:02:57 +0300 Subject: [PATCH 3/3] Update contributors.yml --- contributors.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.yml b/contributors.yml index 2082053191..17f93e5e17 100644 --- a/contributors.yml +++ b/contributors.yml @@ -281,3 +281,4 @@ - yuleicul - zeromask1337 - zheng-chuang +- levvysokiy