ultimate-express 1.2.23 → 1.2.25

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.2.23",
3
+ "version": "1.2.25",
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/router.js CHANGED
@@ -417,12 +417,18 @@ module.exports = class Router extends EventEmitter {
417
417
  return resolve(this._routeRequest(req, res, 0, this._routes, false, skipUntil));
418
418
  }
419
419
  let callbackindex = 0;
420
- let continueRoute = await this._preprocessRequest(req, res, route);
420
+ const continueRoute = await this._preprocessRequest(req, res, route);
421
421
  if(route.use) {
422
+ const strictRouting = this.get('strict routing');
422
423
  req._stack.push(route.path);
423
- req._opPath =
424
- req.path.replace(this.getFullMountpath(req), '') +
425
- (req.endsWithSlash && req.path !== '/' && this.get('strict routing') ? '/' : '');
424
+ req._opPath = req.path.replace(this.getFullMountpath(req), '');
425
+ if(strictRouting) {
426
+ if(req.endsWithSlash && req.path !== '/') {
427
+ req._opPath += '/';
428
+ }
429
+ } else if(req.endsWithSlash && req.path !== '/') {
430
+ req._opPath = req._opPath.slice(0, -1);
431
+ }
426
432
  req.url = req._opPath + req.urlQuery;
427
433
  if(req.url === '') req.url = '/';
428
434
  }
@@ -431,9 +437,15 @@ module.exports = class Router extends EventEmitter {
431
437
  if(thingamabob === 'route' || thingamabob === 'skipPop') {
432
438
  if(route.use && thingamabob !== 'skipPop') {
433
439
  req._stack.pop();
434
- req._opPath =
435
- (req._stack.length > 0 ? req.path.replace(this.getFullMountpath(req), '') : req.path) +
436
- (req.endsWithSlash && req.path !== '/' && this.get('strict routing') ? '/' : '');
440
+ const strictRouting = this.get('strict routing');
441
+ req._opPath = req._stack.length > 0 ? req.path.replace(this.getFullMountpath(req), '') : req.path;
442
+ if(strictRouting) {
443
+ if(req.endsWithSlash && req.path !== '/') {
444
+ req._opPath += '/';
445
+ }
446
+ } else if(req.endsWithSlash && req.path !== '/' && req._opPath[req._opPath.length - 1] === '/') {
447
+ req._opPath = req._opPath.slice(0, -1);
448
+ }
437
449
  req.url = req._opPath + req.urlQuery;
438
450
  if(req.url === '') req.url = '/';
439
451
  if(req.app.parent && route.callback.constructor.name === 'Application') {
@@ -457,6 +469,9 @@ module.exports = class Router extends EventEmitter {
457
469
  if(callback.settings.mergeParams) {
458
470
  req._paramStack.push(req.params);
459
471
  }
472
+ if(callback.settings['strict routing'] && req.endsWithSlash && req.path !== '/') {
473
+ req._opPath += '/';
474
+ }
460
475
  const routed = await callback._routeRequest(req, res, 0);
461
476
  if(routed) return resolve(true);
462
477
  next();
package/src/view.js CHANGED
@@ -54,6 +54,9 @@ module.exports = class View {
54
54
  this.engine = this.options.engines[this.ext];
55
55
  if(path.isAbsolute(name)) {
56
56
  this.path = name;
57
+ if(path.extname(name) === '') {
58
+ this.path += this.ext;
59
+ }
57
60
  } else {
58
61
  this.path = path.join(this.root, fileName);
59
62
  }