Skip to content

Commit

Permalink
Slight cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Mar 22, 2018
1 parent e8b86ba commit b20bc61
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Server.js
Expand Up @@ -45,17 +45,16 @@ function middleware(bundler) {
function respond() {
if (bundler.errored) {
return send500();
} else if (!req.url.startsWith(bundler.options.publicURL)) {
// If the URL doesn't start with the public path, send the main HTML bundle
} else if (
!req.url.startsWith(bundler.options.publicURL) ||
path.extname(req.url) === ''
) {
// If the URL doesn't start with the public path, or the URL doesn't
// have a file extension, send the main HTML bundle.
return sendIndex();
} else {
// Otherwise, serve the file from the dist folder
req.url = req.url.slice(bundler.options.publicURL.length);
// If we're serving an html bundle, and the requested path has not file
// extension, serve the index.html. Otherwise go to the file server.
if (bundler.mainAsset.type === 'html' && path.extname(req.url) == "") {
return sendIndex();
}
return serve(req, res, send404);
}
}
Expand Down

0 comments on commit b20bc61

Please sign in to comment.