ultimate-express 1.4.7 → 1.4.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate-express",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "The Ultimate Express. Fastest http server with full Express compatibility, based on uWebSockets.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/response.js CHANGED
@@ -153,7 +153,7 @@ module.exports = class Response extends Writable {
153
153
  this.#pendingChunks.push(chunk);
154
154
  const size = this.#pendingChunks.reduce((acc, chunk) => acc + chunk.byteLength, 0);
155
155
  const now = Date.now();
156
- // the first chunk is set immediately (!this.#lastWriteChunkTime)
156
+ // the first chunk is sent immediately (!this.#lastWriteChunkTime)
157
157
  // the other chunks are sent when watermark is reached (size >= HIGH_WATERMARK)
158
158
  // or if elapsed 100ms of last send (now - this.#lastWriteChunkTime > 100)
159
159
  if (!this.#lastWriteChunkTime || size >= HIGH_WATERMARK || now - this.#lastWriteChunkTime > 100) {
package/src/router.js CHANGED
@@ -365,7 +365,7 @@ module.exports = class Router extends EventEmitter {
365
365
  req.route = route;
366
366
  if(route.optimizedParams) {
367
367
  req.params = {...req.optimizedParams};
368
- } else if(typeof route.path === 'string' && (route.path.includes(':') || route.path.includes('*')) && route.pattern instanceof RegExp) {
368
+ } else if(typeof route.path === 'string' && (route.path.includes(':') || route.path.includes('*') || (route.path.includes('(') && route.path.includes(')'))) && route.pattern instanceof RegExp) {
369
369
  let path = req._originalPath;
370
370
  if(req._stack.length > 0) {
371
371
  path = path.replace(this.getFullMountpath(req), '');
package/src/utils.js CHANGED
@@ -57,7 +57,7 @@ function patternToRegex(pattern, isPrefix = false) {
57
57
  .replaceAll('*', '(.*)') // Convert * to .*
58
58
  .replace(/\/:(\w+)(\(.+?\))?\??/g, (match, param, regex) => {
59
59
  const optional = match.endsWith('?');
60
- return `\\/${optional ? '?' : ''}?(?<${param}>${regex ? regex + '($|\\/)' : '[^/]+'})${optional ? '?' : ''}`;
60
+ return `\\/${optional ? '?' : ''}(?<${param}>${regex ? regex + '($|\\/)' : '[^/]+'})${optional ? '?' : ''}`;
61
61
  }); // Convert :param to capture group
62
62
 
63
63
  return new RegExp(`^${regexPattern}${isPrefix ? '(?=$|\/)' : '$'}`);