@modern-js/prod-server 1.22.4 → 1.22.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
@@ -1,5 +1,16 @@
1
1
  # @modern-js/prod-server
2
2
 
3
+ ## 1.22.5
4
+
5
+ ### Patch Changes
6
+
7
+ - cc2d4fc: fix(prod-server): failed to match html inside config/public directory
8
+
9
+ fix(prod-server): 修复无法正确匹配 config/public 目录下的 HTML 文件 URL 的问题
10
+
11
+ - @modern-js/server-core@1.22.5
12
+ - @modern-js/utils@1.22.5
13
+
3
14
  ## 1.22.4
4
15
 
5
16
  ### Patch Changes
@@ -3,7 +3,16 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
3
3
  import { removeTailSlash } from '@modern-js/utils';
4
4
  import { match, pathToRegexp } from 'path-to-regexp';
5
5
  import { toPath } from "../../utils";
6
- import { ModernRoute } from "./route"; // eslint-disable-next-line no-useless-escape
6
+ import { ModernRoute } from "./route";
7
+
8
+ const removeHtmlSuffix = url => {
9
+ if (url.endsWith('.html')) {
10
+ return url.slice(0, -5);
11
+ }
12
+
13
+ return url;
14
+ }; // eslint-disable-next-line no-useless-escape
15
+
7
16
 
8
17
  const regCharsDetector = /[^a-zA-Z\-_0-9\/\.]/;
9
18
  export class RouteMatcher {
@@ -57,17 +66,16 @@ export class RouteMatcher {
57
66
 
58
67
  matchUrlPath(requestUrl) {
59
68
  let urlWithoutSlash = requestUrl.endsWith('/') && requestUrl !== '/' ? requestUrl.slice(0, -1) : requestUrl;
60
-
61
- if (urlWithoutSlash.endsWith('.html')) {
62
- urlWithoutSlash = urlWithoutSlash.slice(0, -5);
63
- }
69
+ urlWithoutSlash = removeHtmlSuffix(urlWithoutSlash);
64
70
 
65
71
  if (this.urlMatcher) {
66
72
  return Boolean(this.urlMatcher(urlWithoutSlash));
67
73
  } else {
68
- if (urlWithoutSlash.startsWith(this.urlPath)) {
74
+ const urlPath = removeHtmlSuffix(this.urlPath);
75
+
76
+ if (urlWithoutSlash.startsWith(urlPath)) {
69
77
  // avoid /abcd match /a
70
- if (this.urlPath !== '/' && urlWithoutSlash.length > this.urlPath.length && !urlWithoutSlash.startsWith(`${this.urlPath}/`)) {
78
+ if (urlPath !== '/' && urlWithoutSlash.length > urlPath.length && !urlWithoutSlash.startsWith(`${urlPath}/`)) {
71
79
  return false;
72
80
  }
73
81
 
@@ -15,7 +15,15 @@ var _route = require("./route");
15
15
 
16
16
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
17
 
18
- // eslint-disable-next-line no-useless-escape
18
+ const removeHtmlSuffix = url => {
19
+ if (url.endsWith('.html')) {
20
+ return url.slice(0, -5);
21
+ }
22
+
23
+ return url;
24
+ }; // eslint-disable-next-line no-useless-escape
25
+
26
+
19
27
  const regCharsDetector = /[^a-zA-Z\-_0-9\/\.]/;
20
28
 
21
29
  class RouteMatcher {
@@ -69,17 +77,16 @@ class RouteMatcher {
69
77
 
70
78
  matchUrlPath(requestUrl) {
71
79
  let urlWithoutSlash = requestUrl.endsWith('/') && requestUrl !== '/' ? requestUrl.slice(0, -1) : requestUrl;
72
-
73
- if (urlWithoutSlash.endsWith('.html')) {
74
- urlWithoutSlash = urlWithoutSlash.slice(0, -5);
75
- }
80
+ urlWithoutSlash = removeHtmlSuffix(urlWithoutSlash);
76
81
 
77
82
  if (this.urlMatcher) {
78
83
  return Boolean(this.urlMatcher(urlWithoutSlash));
79
84
  } else {
80
- if (urlWithoutSlash.startsWith(this.urlPath)) {
85
+ const urlPath = removeHtmlSuffix(this.urlPath);
86
+
87
+ if (urlWithoutSlash.startsWith(urlPath)) {
81
88
  // avoid /abcd match /a
82
- if (this.urlPath !== '/' && urlWithoutSlash.length > this.urlPath.length && !urlWithoutSlash.startsWith(`${this.urlPath}/`)) {
89
+ if (urlPath !== '/' && urlWithoutSlash.length > urlPath.length && !urlWithoutSlash.startsWith(`${urlPath}/`)) {
83
90
  return false;
84
91
  }
85
92
 
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.22.4",
14
+ "version": "1.22.5",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -41,8 +41,8 @@
41
41
  "path-to-regexp": "^6.2.0",
42
42
  "serve-static": "^1.14.1",
43
43
  "ua-parser-js": "^0.7.28",
44
- "@modern-js/utils": "1.22.4",
45
- "@modern-js/server-core": "1.22.4"
44
+ "@modern-js/utils": "1.22.5",
45
+ "@modern-js/server-core": "1.22.5"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/cookie": "^0.4.1",
@@ -58,10 +58,10 @@
58
58
  "node-mocks-http": "^1.11.0",
59
59
  "portfinder": "^1.0.28",
60
60
  "typescript": "^4",
61
- "@modern-js/types": "1.22.4",
62
- "@modern-js/core": "1.22.4",
63
- "@scripts/jest-config": "1.22.4",
64
- "@scripts/build": "1.22.4"
61
+ "@modern-js/types": "1.22.5",
62
+ "@modern-js/core": "1.22.5",
63
+ "@scripts/jest-config": "1.22.5",
64
+ "@scripts/build": "1.22.5"
65
65
  },
66
66
  "sideEffects": false,
67
67
  "modernConfig": {