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

Fix bug if url contains dot character #140

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/expressView.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ function ReactEngineView(name, options) {
// when the view name starts with `/` we assume
// that we need to use react router to render.
this.useRouter = (name[0] === '/');

this.addJsxExt = false;
if (this.useRouter) {
name = url.parse(name).path;
if(name.indexOf('.') !== -1){
name += '.jsx';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bodyscripter can you please explain what is being done here? we cannot assume that all files will have jsx extension

this.addJsxExt = true;
}
}

View.call(this, name, options);
Expand All @@ -52,6 +56,11 @@ ReactEngineView.prototype.lookup = function lookup(name) {

ReactEngineView.prototype.render = function render(options, fn) {
debug(format('ReactEngineView :render:'));

if(this.addJsxExt){
this.name = this.name.slice(0, -('.jsx'.length));
}

if (this.useRouter) {
this.engine(this.name, options, fn);
} else {
Expand Down