|
1 | 1 | import { resolvePath } from "react-router"; |
2 | 2 |
|
3 | 3 | describe("resolvePath", () => { |
4 | | - it("does not touch with protocol-less absolute paths", () => { |
5 | | - expect(resolvePath("//google.com")).toMatchObject({ |
6 | | - pathname: "//google.com", |
7 | | - }); |
8 | | - |
9 | | - expect(resolvePath("//google.com/../../path")).toMatchObject({ |
10 | | - pathname: "//google.com/../../path", |
11 | | - }); |
12 | | - |
13 | | - expect(resolvePath("//google.com?q=query#hash")).toMatchObject({ |
14 | | - pathname: "//google.com", |
15 | | - search: "?q=query", |
16 | | - hash: "#hash", |
17 | | - }); |
18 | | - }); |
19 | | - |
20 | 4 | it('resolves absolute paths irrespective of the "from" pathname', () => { |
21 | 5 | expect(resolvePath("/search", "/inbox")).toMatchObject({ |
22 | 6 | pathname: "/search", |
@@ -79,6 +63,32 @@ describe("resolvePath", () => { |
79 | 63 | spy.mockRestore(); |
80 | 64 | }); |
81 | 65 |
|
| 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 | + |
82 | 92 | it('ignores trailing slashes on the "from" pathname when resolving relative paths', () => { |
83 | 93 | expect(resolvePath("../search", "/inbox/")).toMatchObject({ |
84 | 94 | pathname: "/search", |
|
0 commit comments