@midwayjs/core 3.0.0-beta.4 → 3.0.0-beta.5

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 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
+ # [3.0.0-beta.5](https://github.com/midwayjs/midway/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2021-11-25)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * [@match](https://github.com/match) empty args ([#1384](https://github.com/midwayjs/midway/issues/1384)) ([6f90fc9](https://github.com/midwayjs/midway/commit/6f90fc993ff01e078288ff664833c61c02dede51))
12
+ * router sort ([#1383](https://github.com/midwayjs/midway/issues/1383)) ([f253887](https://github.com/midwayjs/midway/commit/f2538876d3eaf7dec55173d86b5b9caeeeb7be64))
13
+
14
+
15
+
16
+
17
+
6
18
  # [3.0.0-beta.4](https://github.com/midwayjs/midway/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2021-11-24)
7
19
 
8
20
 
@@ -71,7 +71,7 @@ class FilterManager {
71
71
  async runResultFilter(result, ctx, res, next) {
72
72
  let returnValue = result;
73
73
  for (const matchData of this.matchFnList) {
74
- if (matchData.matchFn(ctx)) {
74
+ if (matchData.matchFn(ctx, res)) {
75
75
  returnValue = await matchData.target.match(returnValue, ctx, res, next);
76
76
  }
77
77
  }
@@ -229,12 +229,14 @@ class WebRouterCollector {
229
229
  .map(item => {
230
230
  const urlString = item.url.toString();
231
231
  const weightArr = (0, decorator_1.isRegExp)(item.url)
232
- ? urlString.split('/')
232
+ ? urlString.split('\\/')
233
233
  : urlString.split('/');
234
234
  let weight = 0;
235
235
  // 权重,比如通配的不加权,非通配加权,防止通配出现在最前面
236
236
  for (const fragment of weightArr) {
237
- if (fragment.includes(':') || fragment.includes('*')) {
237
+ if (fragment === '' ||
238
+ fragment.includes(':') ||
239
+ fragment.includes('*')) {
238
240
  weight += 0;
239
241
  }
240
242
  else {
@@ -265,12 +267,12 @@ class WebRouterCollector {
265
267
  if (handlerA._category !== handlerB._category) {
266
268
  return handlerB._category - handlerA._category;
267
269
  }
270
+ // 不同权重
271
+ if (handlerA._weight !== handlerB._weight) {
272
+ return handlerB._weight - handlerA._weight;
273
+ }
268
274
  // 不同长度
269
275
  if (handlerA._level === handlerB._level) {
270
- // 不同权重
271
- if (handlerA._weight !== handlerB._weight) {
272
- return handlerB._weight - handlerA._weight;
273
- }
274
276
  if (handlerB._pureRouter === handlerA._pureRouter) {
275
277
  return (handlerA.url.toString().length - handlerB.url.toString().length);
276
278
  }
@@ -14,7 +14,7 @@ export declare type ServiceFactoryConfigOption<OPTIONS> = {
14
14
  [key: string]: PowerPartial<OPTIONS>;
15
15
  };
16
16
  };
17
- declare type ConfigType<T> = T extends (args: any[]) => any ? PowerPartial<ReturnType<T>> : PowerPartial<T>;
17
+ declare type ConfigType<T> = T extends (...args: any[]) => any ? PowerPartial<ReturnType<T>> : PowerPartial<T>;
18
18
  export declare type FileConfigOption<T, K = unknown> = K extends keyof ConfigType<T> ? Pick<ConfigType<T>, K> : ConfigType<T>;
19
19
  /**
20
20
  * 生命周期定义
@@ -211,6 +211,9 @@ const transformRequestObjectByType = (originValue, targetType) => {
211
211
  };
212
212
  exports.transformRequestObjectByType = transformRequestObjectByType;
213
213
  function toPathMatch(pattern) {
214
+ if (typeof pattern === 'boolean') {
215
+ return ctx => pattern;
216
+ }
214
217
  if (typeof pattern === 'string') {
215
218
  const reg = (0, pathToRegexp_1.pathToRegexp)(pattern, [], { end: false });
216
219
  if (reg.global)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.0.0-beta.4",
3
+ "version": "3.0.0-beta.5",
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": "^3.0.0-beta.4",
24
+ "@midwayjs/decorator": "^3.0.0-beta.5",
25
25
  "midway-test-component": "*",
26
26
  "mm": "3",
27
27
  "sinon": "^7.2.2"
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@midwayjs/glob": "^1.0.2",
34
- "@midwayjs/logger": "^3.0.0-beta.4",
34
+ "@midwayjs/logger": "^3.0.0-beta.5",
35
35
  "class-transformer": "^0.4.0",
36
36
  "extend2": "^1.0.0",
37
37
  "picomatch": "^2.2.2",
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=12"
47
47
  },
48
- "gitHead": "02e2144e302f807770b512b0d89da3145b1cbf2e"
48
+ "gitHead": "ab0bf05ae6d13f6435db2f7223202be61d585a1b"
49
49
  }