webpack-dev-server 5.2.1 → 5.2.2

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/client/index.js CHANGED
@@ -164,7 +164,7 @@ if (parsedResourceQuery.overlay) {
164
164
  }, options.overlay);
165
165
  decodeOverlayOptions(options.overlay);
166
166
  }
167
- enabledFeatures.Overlay = true;
167
+ enabledFeatures.Overlay = options.overlay !== false;
168
168
  }
169
169
  if (parsedResourceQuery.logging) {
170
170
  options.logging = parsedResourceQuery.logging;
@@ -143,8 +143,8 @@ var TIMERS_SYMBOL = (typeof Symbol !== "undefined" ? Symbol : function (i) { ret
143
143
  var TIMERS_AGGREGATES_SYMBOL = (typeof Symbol !== "undefined" ? Symbol : function (i) { return i; })("webpack logger aggregated times");
144
144
  var WebpackLogger = /*#__PURE__*/function () {
145
145
  /**
146
- * @param {function(LogTypeEnum, EXPECTED_ANY[]=): void} log log function
147
- * @param {function(string | function(): string): WebpackLogger} getChildLogger function to create child logger
146
+ * @param {(type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} log log function
147
+ * @param {(name: string | (() => string)) => WebpackLogger} getChildLogger function to create child logger
148
148
  */
149
149
  function WebpackLogger(log, getChildLogger) {
150
150
  _classCallCheck(this, WebpackLogger);
@@ -472,13 +472,13 @@ var _require = __webpack_require__(/*! ./Logger */ "./node_modules/webpack/lib/l
472
472
  /** @typedef {import("../../declarations/WebpackOptions").FilterTypes} FilterTypes */
473
473
  /** @typedef {import("./Logger").LogTypeEnum} LogTypeEnum */
474
474
 
475
- /** @typedef {function(string): boolean} FilterFunction */
476
- /** @typedef {function(string, LogTypeEnum, EXPECTED_ANY[]=): void} LoggingFunction */
475
+ /** @typedef {(item: string) => boolean} FilterFunction */
476
+ /** @typedef {(value: string, type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} LoggingFunction */
477
477
 
478
478
  /**
479
479
  * @typedef {object} LoggerConsole
480
- * @property {function(): void} clear
481
- * @property {function(): void} trace
480
+ * @property {() => void} clear
481
+ * @property {() => void} trace
482
482
  * @property {(...args: EXPECTED_ANY[]) => void} info
483
483
  * @property {(...args: EXPECTED_ANY[]) => void} log
484
484
  * @property {(...args: EXPECTED_ANY[]) => void} warn
@@ -555,7 +555,6 @@ module.exports = function (_ref) {
555
555
  typeof debug === "boolean" ? [function () {
556
556
  return debug;
557
557
  }] : /** @type {FilterItemTypes[]} */[].concat(debug).map(filterToFunction);
558
- /** @type {number} */
559
558
  var loglevel = LogLevel["".concat(level)] || 0;
560
559
 
561
560
  /**
package/client/overlay.js CHANGED
@@ -598,8 +598,9 @@ var createOverlay = function createOverlay(options) {
598
598
  if (!error && !message) {
599
599
  return;
600
600
  }
601
+
601
602
  // if error stack indicates a React error boundary caught the error, do not show overlay.
602
- if (error.stack && error.stack.includes("invokeGuardedCallbackDev")) {
603
+ if (error && error.stack && error.stack.includes("invokeGuardedCallbackDev")) {
603
604
  return;
604
605
  }
605
606
  handleError(error, message);
package/lib/Server.js CHANGED
@@ -1986,6 +1986,13 @@ class Server {
1986
1986
  const headers =
1987
1987
  /** @type {{ [key: string]: string | undefined }} */
1988
1988
  (req.headers);
1989
+ const headerName = headers[":authority"] ? ":authority" : "host";
1990
+
1991
+ if (this.isValidHost(headers, headerName, false)) {
1992
+ next();
1993
+ return;
1994
+ }
1995
+
1989
1996
  if (
1990
1997
  headers["sec-fetch-mode"] === "no-cors" &&
1991
1998
  headers["sec-fetch-site"] === "cross-site"
@@ -3088,8 +3095,6 @@ class Server {
3088
3095
  */
3089
3096
  const allHeaders = [];
3090
3097
 
3091
- allHeaders.push({ key: "X_TEST", value: "TEST" });
3092
-
3093
3098
  if (!Array.isArray(headers)) {
3094
3099
  // eslint-disable-next-line guard-for-in
3095
3100
  for (const name in headers) {
@@ -3125,17 +3130,14 @@ class Server {
3125
3130
  // always allow localhost host, for convenience
3126
3131
  // allow if value is in allowedHosts
3127
3132
  if (Array.isArray(allowedHosts) && allowedHosts.length > 0) {
3128
- for (let hostIdx = 0; hostIdx < allowedHosts.length; hostIdx++) {
3129
- /** @type {string} */
3130
- const allowedHost = allowedHosts[hostIdx];
3131
-
3133
+ for (const allowedHost of allowedHosts) {
3132
3134
  if (allowedHost === value) {
3133
3135
  return true;
3134
3136
  }
3135
3137
 
3136
3138
  // support "." as a subdomain wildcard
3137
3139
  // e.g. ".example.com" will allow "example.com", "www.example.com", "subdomain.example.com", etc
3138
- if (allowedHost[0] === ".") {
3140
+ if (allowedHost.startsWith(".")) {
3139
3141
  // "example.com" (value === allowedHost.substring(1))
3140
3142
  // "*.example.com" (value.endsWith(allowedHost))
3141
3143
  if (
@@ -3171,9 +3173,10 @@ class Server {
3171
3173
  * @private
3172
3174
  * @param {{ [key: string]: string | undefined }} headers
3173
3175
  * @param {string} headerToCheck
3176
+ * @param {boolean} validateHost
3174
3177
  * @returns {boolean}
3175
3178
  */
3176
- isValidHost(headers, headerToCheck) {
3179
+ isValidHost(headers, headerToCheck, validateHost = true) {
3177
3180
  if (this.options.allowedHosts === "all") {
3178
3181
  return true;
3179
3182
  }
@@ -3215,19 +3218,15 @@ class Server {
3215
3218
  // For convenience, always allow localhost (hostname === 'localhost')
3216
3219
  // and its subdomains (hostname.endsWith(".localhost")).
3217
3220
  // allow hostname of listening address (hostname === this.options.host)
3218
- const isValidHostname =
3219
- ipaddr.IPv4.isValid(hostname) ||
3220
- ipaddr.IPv6.isValid(hostname) ||
3221
- hostname === "localhost" ||
3222
- hostname.endsWith(".localhost") ||
3223
- hostname === this.options.host;
3224
-
3225
- if (isValidHostname) {
3226
- return true;
3227
- }
3228
-
3229
- // disallow
3230
- return false;
3221
+ const isValidHostname = validateHost
3222
+ ? ipaddr.IPv4.isValid(hostname) ||
3223
+ ipaddr.IPv6.isValid(hostname) ||
3224
+ hostname === "localhost" ||
3225
+ hostname.endsWith(".localhost") ||
3226
+ hostname === this.options.host
3227
+ : false;
3228
+
3229
+ return isValidHostname;
3231
3230
  }
3232
3231
 
3233
3232
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-dev-server",
3
- "version": "5.2.1",
3
+ "version": "5.2.2",
4
4
  "description": "Serves a webpack app. Updates the browser on changes.",
5
5
  "bin": "bin/webpack-dev-server.js",
6
6
  "main": "lib/Server.js",
@@ -62,7 +62,7 @@
62
62
  "connect-history-api-fallback": "^2.0.0",
63
63
  "express": "^4.21.2",
64
64
  "graceful-fs": "^4.2.6",
65
- "http-proxy-middleware": "^2.0.7",
65
+ "http-proxy-middleware": "^2.0.9",
66
66
  "ipaddr.js": "^2.1.0",
67
67
  "launch-editor": "^2.6.1",
68
68
  "open": "^10.0.3",
@@ -93,7 +93,7 @@
93
93
  "@types/trusted-types": "^2.0.2",
94
94
  "acorn": "^8.14.0",
95
95
  "babel-jest": "^29.5.0",
96
- "babel-loader": "^9.2.1",
96
+ "babel-loader": "^10.0.0",
97
97
  "body-parser": "^1.19.2",
98
98
  "connect": "^3.7.0",
99
99
  "core-js": "^3.38.1",
@@ -118,7 +118,7 @@
118
118
  "memfs": "^4.14.0",
119
119
  "npm-run-all": "^4.1.5",
120
120
  "prettier": "^3.2.4",
121
- "puppeteer": "^23.6.1",
121
+ "puppeteer": "^24.10.0",
122
122
  "readable-stream": "^4.5.2",
123
123
  "require-from-string": "^2.0.2",
124
124
  "rimraf": "^5.0.5",
@@ -1357,6 +1357,7 @@ declare class Server<
1357
1357
  * @private
1358
1358
  * @param {{ [key: string]: string | undefined }} headers
1359
1359
  * @param {string} headerToCheck
1360
+ * @param {boolean} validateHost
1360
1361
  * @returns {boolean}
1361
1362
  */
1362
1363
  private isValidHost;