Skip to content

Commit

Permalink
fix usage of ES5 features
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Apr 22, 2017
1 parent da20bc2 commit 168e783
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ function Server(compiler, options) {
// Init express server
var app = this.app = new express();

app.all("*", (req, res, next) => {
app.all("*", function(req, res, next) {
if(this.checkHost(req.headers))
return next();
res.send("Invalid Host header");
});
}.bind(this));

// middleware for serving webpack bundle
this.middleware = webpackDevMiddleware(compiler, options);
Expand Down Expand Up @@ -333,10 +333,10 @@ Server.prototype.checkHost = function(headers) {

// get the Host header and extract hostname
// we don't care about port not matching
const hostHeader = headers.host;
var hostHeader = headers.host;
if(!hostHeader) return false;
const idx = hostHeader.indexOf(":");
const hostname = idx >= 0 ? hostHeader.substr(0, idx) : hostHeader;
var idx = hostHeader.indexOf(":");
var hostname = idx >= 0 ? hostHeader.substr(0, idx) : hostHeader;

// always allow localhost host, for convience
if(hostname === "127.0.0.1" || hostname === "localhost") return true;
Expand All @@ -346,8 +346,8 @@ Server.prototype.checkHost = function(headers) {

// also allow public hostname if provided
if(typeof this.publicHost === "string") {
const idxPublic = this.publicHost.indexOf(":");
const publicHostname = idxPublic >= 0 ? this.publicHost.substr(0, idx) : this.publicHost;
var idxPublic = this.publicHost.indexOf(":");
var publicHostname = idxPublic >= 0 ? this.publicHost.substr(0, idx) : this.publicHost;
if(hostname === publicHostname) return true;
}

Expand Down

0 comments on commit 168e783

Please sign in to comment.