Skip to content
This repository was archived by the owner on Jan 22, 2020. It is now read-only.
This repository was archived by the owner on Jan 22, 2020. It is now read-only.

(Bug) React-engine error when req.url store dot character. #139

@ghost

Description

When I do a request that store a dot character, e.x: http://localhost/profile/abc.xyz. Then, nodejs will notify 'error: uncaughtException: Cannot find module 'xyz'. I know it occur due to the ReactEngineView function in the react-engine/lib/expressView.js, in depth the ReactEngineView function will call the View function at express/lib/view.js. The View function as the following code:

function View(name, options) {
  var opts = options || {};

  this.defaultEngine = opts.defaultEngine;
  this.ext = extname(name); // <--------- Error here
  this.name = name;
  this.root = opts.root;

  if (!this.ext && !this.defaultEngine) {
    throw new Error('No default engine was specified and no extension was provided.');
  }

  var fileName = name;

  if (!this.ext) {
    // get extension from default engine name
    this.ext = this.defaultEngine[0] !== '.'
      ? '.' + this.defaultEngine
      : this.defaultEngine;

    fileName += this.ext;
  }
  console.log(this.ext);
  if (!opts.engines[this.ext]) {
    // load engine
    opts.engines[this.ext] = require(this.ext.substr(1)).__express;
  }

  // store loaded engine
  this.engine = opts.engines[this.ext];

  // lookup path
  this.path = this.lookup(fileName);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions