@modern-js/prod-server 2.1.0 → 2.3.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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @modern-js/prod-server
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [fd5a3ed]
8
+ - Updated dependencies [6ca1c0b]
9
+ - Updated dependencies [89b6739]
10
+ - @modern-js/utils@2.3.0
11
+ - @modern-js/server-core@2.3.0
12
+
13
+ ## 2.2.0
14
+
15
+ ### Patch Changes
16
+
17
+ - 2d3e3df: fix(prod-server): failed to match html inside config/public directory
18
+
19
+ fix(prod-server): 修复无法正确匹配 config/public 目录下的 HTML 文件 URL 的问题
20
+
21
+ - Updated dependencies [49eff0c]
22
+ - @modern-js/utils@2.2.0
23
+ - @modern-js/server-core@2.2.0
24
+
3
25
  ## 2.1.0
4
26
 
5
27
  ### Patch Changes
@@ -5,6 +5,12 @@ import {
5
5
  } from "path-to-regexp";
6
6
  import { ModernRoute } from "./route";
7
7
  const removeTailSlash = (s) => s.replace(/\/+$/, "");
8
+ const removeHtmlSuffix = (url) => {
9
+ if (url.endsWith(".html")) {
10
+ return url.slice(0, -5);
11
+ }
12
+ return url;
13
+ };
8
14
  const toPath = (reg, params) => {
9
15
  const fn = compile(reg, { encode: encodeURIComponent });
10
16
  return fn(params);
@@ -44,14 +50,13 @@ class RouteMatcher {
44
50
  }
45
51
  matchUrlPath(requestUrl) {
46
52
  let urlWithoutSlash = requestUrl.endsWith("/") && requestUrl !== "/" ? requestUrl.slice(0, -1) : requestUrl;
47
- if (urlWithoutSlash.endsWith(".html")) {
48
- urlWithoutSlash = urlWithoutSlash.slice(0, -5);
49
- }
53
+ urlWithoutSlash = removeHtmlSuffix(urlWithoutSlash);
50
54
  if (this.urlMatcher) {
51
55
  return Boolean(this.urlMatcher(urlWithoutSlash));
52
56
  } else {
53
- if (urlWithoutSlash.startsWith(this.urlPath)) {
54
- if (this.urlPath !== "/" && urlWithoutSlash.length > this.urlPath.length && !urlWithoutSlash.startsWith(`${this.urlPath}/`)) {
57
+ const urlPath = removeHtmlSuffix(this.urlPath);
58
+ if (urlWithoutSlash.startsWith(urlPath)) {
59
+ if (urlPath !== "/" && urlWithoutSlash.length > urlPath.length && !urlWithoutSlash.startsWith(`${urlPath}/`)) {
55
60
  return false;
56
61
  }
57
62
  return true;
@@ -23,6 +23,12 @@ module.exports = __toCommonJS(matcher_exports);
23
23
  var import_path_to_regexp = require("path-to-regexp");
24
24
  var import_route = require("./route");
25
25
  const removeTailSlash = (s) => s.replace(/\/+$/, "");
26
+ const removeHtmlSuffix = (url) => {
27
+ if (url.endsWith(".html")) {
28
+ return url.slice(0, -5);
29
+ }
30
+ return url;
31
+ };
26
32
  const toPath = (reg, params) => {
27
33
  const fn = (0, import_path_to_regexp.compile)(reg, { encode: encodeURIComponent });
28
34
  return fn(params);
@@ -62,14 +68,13 @@ class RouteMatcher {
62
68
  }
63
69
  matchUrlPath(requestUrl) {
64
70
  let urlWithoutSlash = requestUrl.endsWith("/") && requestUrl !== "/" ? requestUrl.slice(0, -1) : requestUrl;
65
- if (urlWithoutSlash.endsWith(".html")) {
66
- urlWithoutSlash = urlWithoutSlash.slice(0, -5);
67
- }
71
+ urlWithoutSlash = removeHtmlSuffix(urlWithoutSlash);
68
72
  if (this.urlMatcher) {
69
73
  return Boolean(this.urlMatcher(urlWithoutSlash));
70
74
  } else {
71
- if (urlWithoutSlash.startsWith(this.urlPath)) {
72
- if (this.urlPath !== "/" && urlWithoutSlash.length > this.urlPath.length && !urlWithoutSlash.startsWith(`${this.urlPath}/`)) {
75
+ const urlPath = removeHtmlSuffix(this.urlPath);
76
+ if (urlWithoutSlash.startsWith(urlPath)) {
77
+ if (urlPath !== "/" && urlWithoutSlash.length > urlPath.length && !urlWithoutSlash.startsWith(`${urlPath}/`)) {
73
78
  return false;
74
79
  }
75
80
  return true;
@@ -35,6 +35,12 @@ import { ModernRoute } from "./route";
35
35
  var removeTailSlash = function(s) {
36
36
  return s.replace(/\/+$/, "");
37
37
  };
38
+ var removeHtmlSuffix = function(url) {
39
+ if (url.endsWith(".html")) {
40
+ return url.slice(0, -5);
41
+ }
42
+ return url;
43
+ };
38
44
  var toPath = function(reg, params) {
39
45
  var fn = compile(reg, {
40
46
  encode: encodeURIComponent
@@ -93,14 +99,13 @@ var RouteMatcher = /*#__PURE__*/ function() {
93
99
  key: "matchUrlPath",
94
100
  value: function matchUrlPath(requestUrl) {
95
101
  var urlWithoutSlash = requestUrl.endsWith("/") && requestUrl !== "/" ? requestUrl.slice(0, -1) : requestUrl;
96
- if (urlWithoutSlash.endsWith(".html")) {
97
- urlWithoutSlash = urlWithoutSlash.slice(0, -5);
98
- }
102
+ urlWithoutSlash = removeHtmlSuffix(urlWithoutSlash);
99
103
  if (this.urlMatcher) {
100
104
  return Boolean(this.urlMatcher(urlWithoutSlash));
101
105
  } else {
102
- if (urlWithoutSlash.startsWith(this.urlPath)) {
103
- if (this.urlPath !== "/" && urlWithoutSlash.length > this.urlPath.length && !urlWithoutSlash.startsWith("".concat(this.urlPath, "/"))) {
106
+ var urlPath = removeHtmlSuffix(this.urlPath);
107
+ if (urlWithoutSlash.startsWith(urlPath)) {
108
+ if (urlPath !== "/" && urlWithoutSlash.length > urlPath.length && !urlWithoutSlash.startsWith("".concat(urlPath, "/"))) {
104
109
  return false;
105
110
  }
106
111
  return true;
@@ -3,7 +3,7 @@
3
3
  /// <reference types="node" />
4
4
  /// <reference types="node" />
5
5
  /// <reference types="node/http" />
6
- /// <reference types=".dts-temp/N8FO3uCQ2aiIAC1YMk0KH/src/type" />
6
+ /// <reference types=".dts-temp/MNvjnPYrkhAy5-K0yn6cD/src/type" />
7
7
  import { IncomingMessage, ServerResponse } from 'http';
8
8
  import { URL } from 'url';
9
9
  import qs from 'querystring';
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node/http" />
3
- /// <reference types=".dts-temp/N8FO3uCQ2aiIAC1YMk0KH/src/type" />
3
+ /// <reference types=".dts-temp/MNvjnPYrkhAy5-K0yn6cD/src/type" />
4
4
  import { IncomingMessage } from 'http';
5
5
  import type { OutputNormalizedConfig, HtmlNormalizedConfig } from '@modern-js/server-core';
6
6
  export declare const debug: any;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.1.0",
14
+ "version": "2.3.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -55,8 +55,8 @@
55
55
  "merge-deep": "^3.0.3",
56
56
  "path-to-regexp": "^6.2.0",
57
57
  "serve-static": "^1.14.1",
58
- "@modern-js/utils": "2.1.0",
59
- "@modern-js/server-core": "2.1.0"
58
+ "@modern-js/utils": "2.3.0",
59
+ "@modern-js/server-core": "2.3.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/cookie": "^0.4.1",
@@ -72,10 +72,10 @@
72
72
  "node-mocks-http": "^1.11.0",
73
73
  "portfinder": "^1.0.28",
74
74
  "typescript": "^4",
75
- "@modern-js/types": "2.1.0",
76
- "@modern-js/server-core": "2.1.0",
77
- "@scripts/build": "2.1.0",
78
- "@scripts/jest-config": "2.1.0"
75
+ "@modern-js/types": "2.3.0",
76
+ "@modern-js/server-core": "2.3.0",
77
+ "@scripts/build": "2.3.0",
78
+ "@scripts/jest-config": "2.3.0"
79
79
  },
80
80
  "sideEffects": false,
81
81
  "publishConfig": {