Skip to content

Commit dab249a

Browse files
committed
Add change file
1 parent 2ca2af8 commit dab249a

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix double slash normalization for `useNavigate` colon urls
2+
3+
- As a reminder, `navigate()` is only intended for navigations within the React Router application and not for external navigations to other domains
4+
- This change may be a breaking bug fix if you are using `navigate` for external navigations

‎packages/react-router/__tests__/resolvePath-test.tsx‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,32 @@ describe("resolvePath", () => {
6363
spy.mockRestore();
6464
});
6565

66+
it("handles relative paths with an embedded colon", () => {
67+
expect(resolvePath("foo:bar", "/")).toMatchObject({
68+
pathname: "/foo:bar",
69+
});
70+
71+
expect(resolvePath("./foo:bar", "/")).toMatchObject({
72+
pathname: "/foo:bar",
73+
});
74+
75+
expect(resolvePath("../foo:bar", "/")).toMatchObject({
76+
pathname: "/foo:bar",
77+
});
78+
79+
expect(resolvePath("foo:bar", "/path")).toMatchObject({
80+
pathname: "/path/foo:bar",
81+
});
82+
83+
expect(resolvePath("./foo:bar", "/path")).toMatchObject({
84+
pathname: "/path/foo:bar",
85+
});
86+
87+
expect(resolvePath("../foo:bar", "/path")).toMatchObject({
88+
pathname: "/foo:bar",
89+
});
90+
});
91+
6692
it('ignores trailing slashes on the "from" pathname when resolving relative paths', () => {
6793
expect(resolvePath("../search", "/inbox/")).toMatchObject({
6894
pathname: "/search",

0 commit comments

Comments
 (0)