@modern-js/prod-server 1.22.4 → 1.22.6
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,23 @@
|
|
|
1
1
|
# @modern-js/prod-server
|
|
2
2
|
|
|
3
|
+
## 1.22.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @modern-js/server-core@1.22.6
|
|
8
|
+
- @modern-js/utils@1.22.6
|
|
9
|
+
|
|
10
|
+
## 1.22.5
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- cc2d4fc: fix(prod-server): failed to match html inside config/public directory
|
|
15
|
+
|
|
16
|
+
fix(prod-server): 修复无法正确匹配 config/public 目录下的 HTML 文件 URL 的问题
|
|
17
|
+
|
|
18
|
+
- @modern-js/server-core@1.22.5
|
|
19
|
+
- @modern-js/utils@1.22.5
|
|
20
|
+
|
|
3
21
|
## 1.22.4
|
|
4
22
|
|
|
5
23
|
### 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";
|
|
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
|
-
|
|
74
|
+
const urlPath = removeHtmlSuffix(this.urlPath);
|
|
75
|
+
|
|
76
|
+
if (urlWithoutSlash.startsWith(urlPath)) {
|
|
69
77
|
// avoid /abcd match /a
|
|
70
|
-
if (
|
|
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
|
-
|
|
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
|
-
|
|
85
|
+
const urlPath = removeHtmlSuffix(this.urlPath);
|
|
86
|
+
|
|
87
|
+
if (urlWithoutSlash.startsWith(urlPath)) {
|
|
81
88
|
// avoid /abcd match /a
|
|
82
|
-
if (
|
|
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.
|
|
14
|
+
"version": "1.22.6",
|
|
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.
|
|
45
|
-
"@modern-js/server-core": "1.22.
|
|
44
|
+
"@modern-js/utils": "1.22.6",
|
|
45
|
+
"@modern-js/server-core": "1.22.6"
|
|
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.
|
|
62
|
-
"@modern-js/core": "1.22.
|
|
63
|
-
"@scripts/jest-config": "1.22.
|
|
64
|
-
"@scripts/build": "1.22.
|
|
61
|
+
"@modern-js/types": "1.22.6",
|
|
62
|
+
"@modern-js/core": "1.22.6",
|
|
63
|
+
"@scripts/jest-config": "1.22.6",
|
|
64
|
+
"@scripts/build": "1.22.6"
|
|
65
65
|
},
|
|
66
66
|
"sideEffects": false,
|
|
67
67
|
"modernConfig": {
|