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

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

Open
ghost opened this issue Feb 22, 2016 · 1 comment
Open

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

ghost opened this issue Feb 22, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 22, 2016

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);
}
@ghost
Copy link
Author

ghost commented Feb 22, 2016

I have created a PR at #140

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants