@midwayjs/core 2.13.4 → 2.14.0
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/util/webRouterCollector.js +8 -6
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.14.0](https://github.com/midwayjs/midway/compare/v2.13.5...v2.14.0) (2021-12-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* express routing middleware takes effect at the controller level ([#1364](https://github.com/midwayjs/midway/issues/1364)) ([5d5f299](https://github.com/midwayjs/midway/commit/5d5f2992be116ca71b21f01fd782e3a2ac072496))
|
|
12
|
+
* router sort ([#1383](https://github.com/midwayjs/midway/issues/1383)) ([6b3ab56](https://github.com/midwayjs/midway/commit/6b3ab56a0525435c67f9730742aa1573d61ea0fc))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [2.13.4](https://github.com/midwayjs/midway/compare/v2.13.3...v2.13.4) (2021-10-21)
|
|
7
19
|
|
|
8
20
|
|
package/README.md
CHANGED
|
@@ -261,12 +261,14 @@ class WebRouterCollector {
|
|
|
261
261
|
.map(item => {
|
|
262
262
|
const urlString = item.url.toString();
|
|
263
263
|
const weightArr = (0, decorator_1.isRegExp)(item.url)
|
|
264
|
-
? urlString.split('
|
|
264
|
+
? urlString.split('\\/')
|
|
265
265
|
: urlString.split('/');
|
|
266
266
|
let weight = 0;
|
|
267
267
|
// 权重,比如通配的不加权,非通配加权,防止通配出现在最前面
|
|
268
268
|
for (const fragment of weightArr) {
|
|
269
|
-
if (fragment
|
|
269
|
+
if (fragment === '' ||
|
|
270
|
+
fragment.includes(':') ||
|
|
271
|
+
fragment.includes('*')) {
|
|
270
272
|
weight += 0;
|
|
271
273
|
}
|
|
272
274
|
else {
|
|
@@ -297,12 +299,12 @@ class WebRouterCollector {
|
|
|
297
299
|
if (handlerA._category !== handlerB._category) {
|
|
298
300
|
return handlerB._category - handlerA._category;
|
|
299
301
|
}
|
|
302
|
+
// 不同权重
|
|
303
|
+
if (handlerA._weight !== handlerB._weight) {
|
|
304
|
+
return handlerB._weight - handlerA._weight;
|
|
305
|
+
}
|
|
300
306
|
// 不同长度
|
|
301
307
|
if (handlerA._level === handlerB._level) {
|
|
302
|
-
// 不同权重
|
|
303
|
-
if (handlerA._weight !== handlerB._weight) {
|
|
304
|
-
return handlerB._weight - handlerA._weight;
|
|
305
|
-
}
|
|
306
308
|
if (handlerB._pureRouter === handlerA._pureRouter) {
|
|
307
309
|
return (handlerA.url.toString().length - handlerB.url.toString().length);
|
|
308
310
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@midwayjs/decorator": "^2.
|
|
24
|
+
"@midwayjs/decorator": "^2.14.0",
|
|
25
25
|
"chai": "^4.2.0",
|
|
26
26
|
"midway-test-component": "*",
|
|
27
27
|
"mm": "3",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">= 10.0.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "5fd716b0e731162d8e9f0931790fde7402fb83de"
|
|
55
55
|
}
|