@esmx/router 3.0.0-rc.29 → 3.0.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.zh-CN.md +82 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.mjs +0 -1
- package/package.json +3 -3
- package/src/index.ts +0 -3
- package/dist/index.test.d.ts +0 -1
- package/dist/index.test.mjs +0 -8
- package/dist/location.test.d.ts +0 -8
- package/dist/location.test.mjs +0 -370
- package/dist/matcher.test.d.ts +0 -1
- package/dist/matcher.test.mjs +0 -1492
- package/dist/micro-app.dom.test.d.ts +0 -1
- package/dist/micro-app.dom.test.mjs +0 -532
- package/dist/navigation.test.d.ts +0 -1
- package/dist/navigation.test.mjs +0 -681
- package/dist/route-task.test.d.ts +0 -1
- package/dist/route-task.test.mjs +0 -673
- package/dist/route-transition.test.d.ts +0 -1
- package/dist/route-transition.test.mjs +0 -146
- package/dist/route.test.d.ts +0 -1
- package/dist/route.test.mjs +0 -1664
- package/dist/router-back.test.d.ts +0 -1
- package/dist/router-back.test.mjs +0 -361
- package/dist/router-forward.test.d.ts +0 -1
- package/dist/router-forward.test.mjs +0 -376
- package/dist/router-go.test.d.ts +0 -1
- package/dist/router-go.test.mjs +0 -73
- package/dist/router-guards-cleanup.test.d.ts +0 -1
- package/dist/router-guards-cleanup.test.mjs +0 -437
- package/dist/router-push.test.d.ts +0 -1
- package/dist/router-push.test.mjs +0 -115
- package/dist/router-replace.test.d.ts +0 -1
- package/dist/router-replace.test.mjs +0 -114
- package/dist/router-resolve.test.d.ts +0 -1
- package/dist/router-resolve.test.mjs +0 -393
- package/dist/router-restart-app.dom.test.d.ts +0 -1
- package/dist/router-restart-app.dom.test.mjs +0 -616
- package/dist/router-window-navigation.test.d.ts +0 -1
- package/dist/router-window-navigation.test.mjs +0 -359
- package/dist/util.test.d.ts +0 -1
- package/dist/util.test.mjs +0 -1020
- package/src/index.test.ts +0 -9
- package/src/location.test.ts +0 -406
- package/src/matcher.test.ts +0 -1685
- package/src/micro-app.dom.test.ts +0 -708
- package/src/navigation.test.ts +0 -858
- package/src/route-task.test.ts +0 -901
- package/src/route-transition.test.ts +0 -178
- package/src/route.test.ts +0 -2014
- package/src/router-back.test.ts +0 -487
- package/src/router-forward.test.ts +0 -506
- package/src/router-go.test.ts +0 -91
- package/src/router-guards-cleanup.test.ts +0 -595
- package/src/router-push.test.ts +0 -140
- package/src/router-replace.test.ts +0 -139
- package/src/router-resolve.test.ts +0 -475
- package/src/router-restart-app.dom.test.ts +0 -783
- package/src/router-window-navigation.test.ts +0 -457
- package/src/util.test.ts +0 -1262
package/README.zh-CN.md
CHANGED
|
@@ -65,6 +65,87 @@ await router.push('/about');
|
|
|
65
65
|
|
|
66
66
|
访问[官方文档](https://www.esmnext.com)获取详细的使用指南和 API 参考。
|
|
67
67
|
|
|
68
|
+
### 路由导航时大致的流程说明
|
|
69
|
+
|
|
70
|
+
```mermaid
|
|
71
|
+
flowchart TD
|
|
72
|
+
start(["Start"]):::Terminal --> normalizeURL["normalizeURL"]
|
|
73
|
+
normalizeURL --> isExternalUrl{"是站内地址"}:::Decision
|
|
74
|
+
isExternalUrl -- Yes --> matchInRouteTable["在路由表内匹配"]
|
|
75
|
+
isExternalUrl -- No --> fallback["fallback"] --> End
|
|
76
|
+
matchInRouteTable --> isExist{"存在匹配项"}:::Decision
|
|
77
|
+
isExist -- No --> fallback
|
|
78
|
+
isExist -- Yes --> execGuard["执行其他回调钩子/守卫"] --> End(["End"]):::Terminal
|
|
79
|
+
classDef Terminal fill:#FFF9C4,color:#000
|
|
80
|
+
classDef Decision fill:#C8E6C9,color:#000
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### 路由钩子管道
|
|
84
|
+
|
|
85
|
+
| | fallback | override | beforeLeave | beforeEach | beforeUpdate | beforeEnter | asyncComponent | confirm |
|
|
86
|
+
|---------|----------|----------|-------------|------------|--------------|-------------|----------------|---------|
|
|
87
|
+
| `push` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
88
|
+
| `replace` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
89
|
+
| `pushWindow` | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ✅ |
|
|
90
|
+
| `pushLayer` | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ✅ |
|
|
91
|
+
| `replaceWindow` | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ |
|
|
92
|
+
| `restartApp` | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
93
|
+
| `unknown` | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
94
|
+
|
|
95
|
+
```mermaid
|
|
96
|
+
gantt
|
|
97
|
+
title 路由钩子执行对比
|
|
98
|
+
dateFormat X
|
|
99
|
+
axisFormat %s
|
|
100
|
+
section push<br>replace
|
|
101
|
+
fallback :0, 1
|
|
102
|
+
override :1, 2
|
|
103
|
+
beforeLeave :2, 3
|
|
104
|
+
beforeEach :3, 4
|
|
105
|
+
beforeUpdate :4, 5
|
|
106
|
+
beforeEnter :5, 6
|
|
107
|
+
asyncComponent:6, 7
|
|
108
|
+
confirm :7, 8
|
|
109
|
+
section pushWindow<br>pushLayer
|
|
110
|
+
fallback :0, 1
|
|
111
|
+
override :1, 2
|
|
112
|
+
beforeEach :3, 4
|
|
113
|
+
confirm :7, 8
|
|
114
|
+
section replaceWindow
|
|
115
|
+
fallback :0, 1
|
|
116
|
+
override :1, 2
|
|
117
|
+
beforeLeave :2, 3
|
|
118
|
+
beforeEach :3, 4
|
|
119
|
+
confirm :7, 8
|
|
120
|
+
section restartApp<br>unknown
|
|
121
|
+
fallback :0, 1
|
|
122
|
+
beforeLeave :2, 3
|
|
123
|
+
beforeEach :3, 4
|
|
124
|
+
beforeUpdate :4, 5
|
|
125
|
+
beforeEnter :5, 6
|
|
126
|
+
asyncComponent:6, 7
|
|
127
|
+
confirm :7, 8
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### 钩子函数说明
|
|
131
|
+
|
|
132
|
+
- **fallback**: 处理未匹配的路由
|
|
133
|
+
- **override**: 允许路由重写逻辑
|
|
134
|
+
- **beforeLeave**: 离开当前路由前执行
|
|
135
|
+
- **beforeEach**: 全局导航守卫
|
|
136
|
+
- **beforeUpdate**: 路由更新前执行(相同组件)
|
|
137
|
+
- **beforeEnter**: 进入新路由前执行
|
|
138
|
+
- **asyncComponent**: 加载异步组件
|
|
139
|
+
- **confirm**: 最终确认和导航执行
|
|
140
|
+
|
|
141
|
+
#### 路由类型特点
|
|
142
|
+
|
|
143
|
+
- **标准导航** (`push`、`replace`): 执行完整的钩子链
|
|
144
|
+
- **窗口操作** (`pushWindow`、`replaceWindow`): 简化的钩子链,主要用于窗口级别的导航
|
|
145
|
+
- **层级操作** (`pushLayer`): 最简化的钩子链,用于层级导航
|
|
146
|
+
- **应用重启** (`restartApp`): 完整钩子链但跳过 override
|
|
147
|
+
- **未知类型** (`unknown`): 完整钩子链但跳过 override,作为默认处理
|
|
148
|
+
|
|
68
149
|
## 📄 许可证
|
|
69
150
|
|
|
70
|
-
MIT © [Esmx Team](https://github.com/esmnext/esmx)
|
|
151
|
+
MIT © [Esmx Team](https://github.com/esmnext/esmx)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { Router } from './router';
|
|
2
2
|
export { Route } from './route';
|
|
3
|
-
export {
|
|
4
|
-
export { type Awaitable, RouterMode, RouteType, type RouteConfirmHook, type RouteConfirmHookResult, type RouteVerifyHook, type RouteHandleHook, type RouteNotifyHook, type RouteMeta, type RouteState, type RouteHandleResult, type RouteMatchType, type RouteLocation, type RouteLocationInput, type RouteConfig, type RouteParsedConfig, type RouteMatchResult, type RouteMatcher, type RouteOptions, type RouteLayerOptions, type RouteLayerResult, type RouterLayerOptions, type RouterMicroApp, type RouterMicroAppCallback, type RouterMicroAppOptions, type RouterOptions, type RouterParsedOptions, type RouterLinkType, type RouterLinkAttributes, type RouterLinkProps, type RouterLinkResolved } from './types';
|
|
3
|
+
export { RouterMode, RouteType, type RouteConfirmHook, type RouteConfirmHookResult, type RouteVerifyHook, type RouteHandleHook, type RouteNotifyHook, type RouteMeta, type RouteState, type RouteHandleResult, type RouteMatchType, type RouteLocation, type RouteLocationInput, type RouteConfig, type RouteParsedConfig, type RouteMatchResult, type RouteMatcher, type RouteOptions, type RouteLayerOptions, type RouteLayerResult, type RouterLayerOptions, type RouterMicroApp, type RouterMicroAppCallback, type RouterMicroAppOptions, type RouterOptions, type RouterParsedOptions, type RouterLinkType, type RouterLinkAttributes, type RouterLinkProps, type RouterLinkResolved } from './types';
|
|
5
4
|
export { RouteError, RouteTaskCancelledError, RouteTaskExecutionError, RouteNavigationAbortedError, RouteSelfRedirectionError } from './error';
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@biomejs/biome": "1.9.4",
|
|
35
|
-
"@esmx/lint": "3.0.0-rc.
|
|
35
|
+
"@esmx/lint": "3.0.0-rc.30",
|
|
36
36
|
"@types/node": "^24.0.0",
|
|
37
37
|
"@vitest/coverage-v8": "3.2.4",
|
|
38
38
|
"happy-dom": "^18.0.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"unbuild": "3.5.0",
|
|
42
42
|
"vitest": "3.2.4"
|
|
43
43
|
},
|
|
44
|
-
"version": "3.0.0-rc.
|
|
44
|
+
"version": "3.0.0-rc.30",
|
|
45
45
|
"type": "module",
|
|
46
46
|
"private": false,
|
|
47
47
|
"exports": {
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"template",
|
|
61
61
|
"public"
|
|
62
62
|
],
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "0bc6815e4a805e552e67a245201a4a75599f58f5"
|
|
64
64
|
}
|
package/src/index.ts
CHANGED
package/dist/index.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/index.test.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { Router as IndexRouter } from "./index.mjs";
|
|
3
|
-
import { Router } from "./router.mjs";
|
|
4
|
-
describe("index exports", () => {
|
|
5
|
-
it("should export Router correctly", () => {
|
|
6
|
-
expect(IndexRouter).toBe(Router);
|
|
7
|
-
});
|
|
8
|
-
});
|
package/dist/location.test.d.ts
DELETED
package/dist/location.test.mjs
DELETED
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { normalizeURL, parseLocation } from "./location.mjs";
|
|
3
|
-
expect.extend({
|
|
4
|
-
toEqURL: (received, expected) => {
|
|
5
|
-
if (!(received instanceof URL)) {
|
|
6
|
-
return {
|
|
7
|
-
message: () => "expected ".concat(received, " to be an instance of URL"),
|
|
8
|
-
pass: false
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
(received = new URL(received)).searchParams.sort();
|
|
12
|
-
(expected = new URL(expected)).searchParams.sort();
|
|
13
|
-
received.hash = received.hash;
|
|
14
|
-
expected.hash = expected.hash;
|
|
15
|
-
return {
|
|
16
|
-
message: () => "expected ".concat(received.href, " to be ").concat(expected.href),
|
|
17
|
-
pass: received.href === expected.href
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
describe("normalizeURL", () => {
|
|
22
|
-
const testCases = [
|
|
23
|
-
{
|
|
24
|
-
input: "//example.com/path",
|
|
25
|
-
base: "https://github.com",
|
|
26
|
-
expected: "http://example.com/path",
|
|
27
|
-
description: "should handle protocol-relative URLs (starting with //)"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
input: "http://github.com/path?a#h",
|
|
31
|
-
base: "http://example.com",
|
|
32
|
-
expected: "http://github.com/path?a#h",
|
|
33
|
-
description: "should handle absolute URLs"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
input: "/path",
|
|
37
|
-
base: "http://example.com/en/",
|
|
38
|
-
expected: "http://example.com/en/path",
|
|
39
|
-
description: "should handle relative paths with a base URL"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
input: "github.com",
|
|
43
|
-
base: "http://example.com",
|
|
44
|
-
expected: "http://example.com/github.com",
|
|
45
|
-
description: "should treat bare domains as relative paths"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
input: new URL("http://example.com/path"),
|
|
49
|
-
base: "http://example.com",
|
|
50
|
-
expected: "http://example.com/path",
|
|
51
|
-
description: "should handle URL objects"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
input: "-a://example.com",
|
|
55
|
-
base: "http://example.com",
|
|
56
|
-
expected: "http://example.com/-a://example.com",
|
|
57
|
-
description: "should treat strings that fail to parse as a protocol as relative paths"
|
|
58
|
-
}
|
|
59
|
-
];
|
|
60
|
-
testCases.forEach(({ input, base, expected, description }) => {
|
|
61
|
-
test(description, () => {
|
|
62
|
-
const result = normalizeURL(input, new URL(base));
|
|
63
|
-
expect(result).toEqURL(expected);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
describe("parseLocation", () => {
|
|
68
|
-
const testCases = [
|
|
69
|
-
{
|
|
70
|
-
input: "/products",
|
|
71
|
-
base: "http://example.com",
|
|
72
|
-
expected: "http://example.com/products",
|
|
73
|
-
description: "should handle string paths"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
input: { path: "/products" },
|
|
77
|
-
base: "http://example.com",
|
|
78
|
-
expected: "http://example.com/products",
|
|
79
|
-
description: "should handle objects with a path property"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
input: { url: "/products" },
|
|
83
|
-
base: "http://example.com",
|
|
84
|
-
expected: "http://example.com/products",
|
|
85
|
-
description: "should handle objects with a url property"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
input: {
|
|
89
|
-
path: "/products",
|
|
90
|
-
query: { id: "123", category: "electronics" }
|
|
91
|
-
},
|
|
92
|
-
base: "http://example.com",
|
|
93
|
-
expected: "http://example.com/products?id=123&category=electronics",
|
|
94
|
-
description: "should handle objects with query parameters"
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
input: { path: "/products", query: { id: "123" }, hash: "details" },
|
|
98
|
-
base: "http://example.com",
|
|
99
|
-
expected: "http://example.com/products?id=123#details",
|
|
100
|
-
description: "should handle objects with a hash"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
input: { path: "/products", queryArray: { tag: ["new", "sale"] } },
|
|
104
|
-
base: "http://example.com",
|
|
105
|
-
expected: "http://example.com/products?tag=new&tag=sale",
|
|
106
|
-
description: "should handle objects with queryArray"
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
input: {
|
|
110
|
-
path: "/products",
|
|
111
|
-
query: { id: "123", category: "electronics" },
|
|
112
|
-
queryArray: { tag: ["new", "sale"] },
|
|
113
|
-
hash: "details"
|
|
114
|
-
},
|
|
115
|
-
base: "http://example.com",
|
|
116
|
-
expected: "http://example.com/products?id=123&category=electronics&tag=new&tag=sale#details",
|
|
117
|
-
description: "should handle complex objects with all properties"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
input: {
|
|
121
|
-
path: "/products",
|
|
122
|
-
hash: "#a?a"
|
|
123
|
-
},
|
|
124
|
-
base: "http://example.com",
|
|
125
|
-
expected: "http://example.com/products#a?a",
|
|
126
|
-
description: "should handle special hash characters correctly"
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
input: {
|
|
130
|
-
path: "/products",
|
|
131
|
-
hash: "#a?a#b"
|
|
132
|
-
},
|
|
133
|
-
base: "http://example.com",
|
|
134
|
-
expected: "http://example.com/products#a?a#b",
|
|
135
|
-
description: "should handle special hash characters correctly"
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
input: {
|
|
139
|
-
path: "/products",
|
|
140
|
-
query: {
|
|
141
|
-
id: null,
|
|
142
|
-
category: void 0,
|
|
143
|
-
symbol: Symbol(),
|
|
144
|
-
fn: async () => "",
|
|
145
|
-
obj: { a: 10 },
|
|
146
|
-
big: /* @__PURE__ */ BigInt("12345678901234567891234567890123456789"),
|
|
147
|
-
a: Number.NaN,
|
|
148
|
-
b: "",
|
|
149
|
-
c: "0",
|
|
150
|
-
d: 0,
|
|
151
|
-
e: 1
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
base: "http://example.com",
|
|
155
|
-
expected: "http://example.com/products?symbol=Symbol()&fn=".concat(String(
|
|
156
|
-
async () => ""
|
|
157
|
-
), "&obj=").concat(String({}), "&big=12345678901234567891234567890123456789&b&c=0&d=0&e=1"),
|
|
158
|
-
description: "should ignore null, undefined, and NaN query parameters"
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
input: { path: "/products", queryArray: { tag: [] } },
|
|
162
|
-
base: "http://example.com",
|
|
163
|
-
expected: "http://example.com/products",
|
|
164
|
-
description: "should handle empty queryArray"
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
input: {
|
|
168
|
-
path: "/products?id=path&a",
|
|
169
|
-
query: { id: "query" }
|
|
170
|
-
},
|
|
171
|
-
base: "http://example.com",
|
|
172
|
-
expected: "http://example.com/products?id=query&a",
|
|
173
|
-
description: "query value should override query parameter in path"
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
input: {
|
|
177
|
-
path: "/products?id=path&a",
|
|
178
|
-
query: { id: "query" },
|
|
179
|
-
queryArray: { id: ["queryArray"] }
|
|
180
|
-
},
|
|
181
|
-
base: "http://example.com",
|
|
182
|
-
expected: "http://example.com/products?id=queryArray&a",
|
|
183
|
-
description: "queryArray value should override query and path parameters"
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
input: {
|
|
187
|
-
path: "/products?id=path&a",
|
|
188
|
-
queryArray: { id: ["queryArray"] }
|
|
189
|
-
},
|
|
190
|
-
base: "http://example.com",
|
|
191
|
-
expected: "http://example.com/products?id=queryArray&a",
|
|
192
|
-
description: "queryArray value should override query parameter in path"
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
input: {
|
|
196
|
-
path: "?a&a=&a&a",
|
|
197
|
-
query: { a: "" },
|
|
198
|
-
queryArray: { a: ["", ""] }
|
|
199
|
-
},
|
|
200
|
-
base: "http://example.com",
|
|
201
|
-
expected: "http://example.com?a&a",
|
|
202
|
-
description: "should handle empty strings and duplicate query parameters correctly"
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
input: { path: "/products?id=123", url: "/products?id=456" },
|
|
206
|
-
base: "http://example.com",
|
|
207
|
-
expected: "http://example.com/products?id=123",
|
|
208
|
-
description: "path should take priority over url when both are present"
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
input: { url: "/products?id=456" },
|
|
212
|
-
base: "http://example.com",
|
|
213
|
-
expected: "http://example.com/products?id=456",
|
|
214
|
-
description: "url should be used when path is not present"
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
input: {},
|
|
218
|
-
base: "http://example.com",
|
|
219
|
-
expected: "http://example.com/",
|
|
220
|
-
description: "empty input object should default to base URL"
|
|
221
|
-
}
|
|
222
|
-
];
|
|
223
|
-
testCases.forEach(({ input, base, expected, description }) => {
|
|
224
|
-
test(description, () => {
|
|
225
|
-
const result = parseLocation(input, new URL(base));
|
|
226
|
-
expect(result).toEqURL(expected);
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
describe("normalizeURL more", () => {
|
|
231
|
-
describe.for(
|
|
232
|
-
// biome-ignore format:
|
|
233
|
-
Object.entries({
|
|
234
|
-
"https://www.esmx.dev": {
|
|
235
|
-
"/": "https://www.esmx.dev/",
|
|
236
|
-
"/new": "https://www.esmx.dev/new",
|
|
237
|
-
"/new/": "https://www.esmx.dev/new/",
|
|
238
|
-
"/new/100": "https://www.esmx.dev/new/100",
|
|
239
|
-
"/new/100/": "https://www.esmx.dev/new/100/",
|
|
240
|
-
"..": "https://www.esmx.dev/",
|
|
241
|
-
"../": "https://www.esmx.dev/",
|
|
242
|
-
"../new": "https://www.esmx.dev/new",
|
|
243
|
-
"../new/": "https://www.esmx.dev/new/",
|
|
244
|
-
"../new/100": "https://www.esmx.dev/new/100",
|
|
245
|
-
"../new/100/": "https://www.esmx.dev/new/100/",
|
|
246
|
-
"": "https://www.esmx.dev/",
|
|
247
|
-
"new": "https://www.esmx.dev/new",
|
|
248
|
-
"new/": "https://www.esmx.dev/new/",
|
|
249
|
-
"new/100": "https://www.esmx.dev/new/100",
|
|
250
|
-
"new/100/": "https://www.esmx.dev/new/100/",
|
|
251
|
-
".": "https://www.esmx.dev/",
|
|
252
|
-
"./": "https://www.esmx.dev/",
|
|
253
|
-
"./new": "https://www.esmx.dev/new",
|
|
254
|
-
"./new/": "https://www.esmx.dev/new/",
|
|
255
|
-
"./new/100": "https://www.esmx.dev/new/100",
|
|
256
|
-
"./new/100/": "https://www.esmx.dev/new/100/",
|
|
257
|
-
".a": "https://www.esmx.dev/.a",
|
|
258
|
-
"..a": "https://www.esmx.dev/..a",
|
|
259
|
-
".a/": "https://www.esmx.dev/.a/",
|
|
260
|
-
"..a/": "https://www.esmx.dev/..a/",
|
|
261
|
-
"new/../.": "https://www.esmx.dev/"
|
|
262
|
-
},
|
|
263
|
-
"https://www.esmx.dev/": {
|
|
264
|
-
"/": "https://www.esmx.dev/",
|
|
265
|
-
"/new": "https://www.esmx.dev/new",
|
|
266
|
-
"/new/": "https://www.esmx.dev/new/",
|
|
267
|
-
"/new/100": "https://www.esmx.dev/new/100",
|
|
268
|
-
"/new/100/": "https://www.esmx.dev/new/100/",
|
|
269
|
-
"..": "https://www.esmx.dev/",
|
|
270
|
-
"../": "https://www.esmx.dev/",
|
|
271
|
-
"../new": "https://www.esmx.dev/new",
|
|
272
|
-
"../new/": "https://www.esmx.dev/new/",
|
|
273
|
-
"../new/100": "https://www.esmx.dev/new/100",
|
|
274
|
-
"../new/100/": "https://www.esmx.dev/new/100/",
|
|
275
|
-
"": "https://www.esmx.dev/",
|
|
276
|
-
"new": "https://www.esmx.dev/new",
|
|
277
|
-
"new/": "https://www.esmx.dev/new/",
|
|
278
|
-
"new/100": "https://www.esmx.dev/new/100",
|
|
279
|
-
"new/100/": "https://www.esmx.dev/new/100/",
|
|
280
|
-
".": "https://www.esmx.dev/",
|
|
281
|
-
"./": "https://www.esmx.dev/",
|
|
282
|
-
"./new": "https://www.esmx.dev/new",
|
|
283
|
-
"./new/": "https://www.esmx.dev/new/",
|
|
284
|
-
"./new/100": "https://www.esmx.dev/new/100",
|
|
285
|
-
"./new/100/": "https://www.esmx.dev/new/100/",
|
|
286
|
-
".a": "https://www.esmx.dev/.a",
|
|
287
|
-
"..a": "https://www.esmx.dev/..a",
|
|
288
|
-
".a/": "https://www.esmx.dev/.a/",
|
|
289
|
-
"..a/": "https://www.esmx.dev/..a/",
|
|
290
|
-
"new/../.": "https://www.esmx.dev/"
|
|
291
|
-
},
|
|
292
|
-
"https://www.esmx.dev/a/b/c": {
|
|
293
|
-
"/": "https://www.esmx.dev/a/b/",
|
|
294
|
-
"/new": "https://www.esmx.dev/a/b/new",
|
|
295
|
-
"/new/": "https://www.esmx.dev/a/b/new/",
|
|
296
|
-
"/new/100": "https://www.esmx.dev/a/b/new/100",
|
|
297
|
-
"/new/100/": "https://www.esmx.dev/a/b/new/100/",
|
|
298
|
-
"..": "https://www.esmx.dev/a/",
|
|
299
|
-
"../": "https://www.esmx.dev/a/",
|
|
300
|
-
"../new": "https://www.esmx.dev/a/new",
|
|
301
|
-
"../new/": "https://www.esmx.dev/a/new/",
|
|
302
|
-
"../new/100": "https://www.esmx.dev/a/new/100",
|
|
303
|
-
"../new/100/": "https://www.esmx.dev/a/new/100/",
|
|
304
|
-
"": "https://www.esmx.dev/a/b/c",
|
|
305
|
-
"new": "https://www.esmx.dev/a/b/new",
|
|
306
|
-
"new/": "https://www.esmx.dev/a/b/new/",
|
|
307
|
-
"new/100": "https://www.esmx.dev/a/b/new/100",
|
|
308
|
-
"new/100/": "https://www.esmx.dev/a/b/new/100/",
|
|
309
|
-
".": "https://www.esmx.dev/a/b/",
|
|
310
|
-
"./": "https://www.esmx.dev/a/b/",
|
|
311
|
-
"./new": "https://www.esmx.dev/a/b/new",
|
|
312
|
-
"./new/": "https://www.esmx.dev/a/b/new/",
|
|
313
|
-
"./new/100": "https://www.esmx.dev/a/b/new/100",
|
|
314
|
-
"./new/100/": "https://www.esmx.dev/a/b/new/100/",
|
|
315
|
-
".a": "https://www.esmx.dev/a/b/.a",
|
|
316
|
-
"..a": "https://www.esmx.dev/a/b/..a",
|
|
317
|
-
".a/": "https://www.esmx.dev/a/b/.a/",
|
|
318
|
-
"..a/": "https://www.esmx.dev/a/b/..a/",
|
|
319
|
-
"new/../.": "https://www.esmx.dev/a/b/",
|
|
320
|
-
"new/.././a/../../x/": "https://www.esmx.dev/a/x/"
|
|
321
|
-
},
|
|
322
|
-
"https://www.esmx.dev/a/b/c/": {
|
|
323
|
-
"/": "https://www.esmx.dev/a/b/c/",
|
|
324
|
-
"/new": "https://www.esmx.dev/a/b/c/new",
|
|
325
|
-
"/new/": "https://www.esmx.dev/a/b/c/new/",
|
|
326
|
-
"/new/100": "https://www.esmx.dev/a/b/c/new/100",
|
|
327
|
-
"/new/100/": "https://www.esmx.dev/a/b/c/new/100/",
|
|
328
|
-
"..": "https://www.esmx.dev/a/b/",
|
|
329
|
-
"../": "https://www.esmx.dev/a/b/",
|
|
330
|
-
"../new": "https://www.esmx.dev/a/b/new",
|
|
331
|
-
"../new/": "https://www.esmx.dev/a/b/new/",
|
|
332
|
-
"../new/100": "https://www.esmx.dev/a/b/new/100",
|
|
333
|
-
"../new/100/": "https://www.esmx.dev/a/b/new/100/",
|
|
334
|
-
"": "https://www.esmx.dev/a/b/c/",
|
|
335
|
-
"new": "https://www.esmx.dev/a/b/c/new",
|
|
336
|
-
"new/": "https://www.esmx.dev/a/b/c/new/",
|
|
337
|
-
"new/100": "https://www.esmx.dev/a/b/c/new/100",
|
|
338
|
-
"new/100/": "https://www.esmx.dev/a/b/c/new/100/",
|
|
339
|
-
".": "https://www.esmx.dev/a/b/c/",
|
|
340
|
-
"./": "https://www.esmx.dev/a/b/c/",
|
|
341
|
-
"./new": "https://www.esmx.dev/a/b/c/new",
|
|
342
|
-
"./new/": "https://www.esmx.dev/a/b/c/new/",
|
|
343
|
-
"./new/100": "https://www.esmx.dev/a/b/c/new/100",
|
|
344
|
-
"./new/100/": "https://www.esmx.dev/a/b/c/new/100/",
|
|
345
|
-
".a": "https://www.esmx.dev/a/b/c/.a",
|
|
346
|
-
"..a": "https://www.esmx.dev/a/b/c/..a",
|
|
347
|
-
".a/": "https://www.esmx.dev/a/b/c/.a/",
|
|
348
|
-
"..a/": "https://www.esmx.dev/a/b/c/..a/",
|
|
349
|
-
"new/.././": "https://www.esmx.dev/a/b/c/",
|
|
350
|
-
"new/.././a/../../x/": "https://www.esmx.dev/a/b/x/"
|
|
351
|
-
}
|
|
352
|
-
})
|
|
353
|
-
)("base: $0", ([base, cases]) => {
|
|
354
|
-
test.each(Object.entries(cases))("input: $0", (input, expected) => {
|
|
355
|
-
const url = normalizeURL(input, new URL(base));
|
|
356
|
-
expect(url).toEqURL(expected);
|
|
357
|
-
const pathSuffix = "?a&b=1&c=2&a=&a=4&base=10#hash";
|
|
358
|
-
const urlWithSuffix = normalizeURL(
|
|
359
|
-
input + pathSuffix,
|
|
360
|
-
new URL(base)
|
|
361
|
-
);
|
|
362
|
-
expect(urlWithSuffix).toEqURL(expected + pathSuffix);
|
|
363
|
-
const urlWithBaseSuffix = normalizeURL(
|
|
364
|
-
input + pathSuffix,
|
|
365
|
-
new URL(base + "?base=base#base")
|
|
366
|
-
);
|
|
367
|
-
expect(urlWithBaseSuffix).toEqURL(expected + pathSuffix);
|
|
368
|
-
});
|
|
369
|
-
});
|
|
370
|
-
});
|
package/dist/matcher.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|