diff --git a/server.js b/server.js index 5f8859e..e473f73 100644 --- a/server.js +++ b/server.js @@ -34,21 +34,21 @@ app.use(express.json()); //serve static files app.use(express.static(path.join(__dirname, '/public'))); -app.get('^/$|/index(.html)?', (req, res) => { +app.get(['/', '/index{.html}'], (req, res) => { //res.sendFile('./views/index.html', { root: __dirname }); res.sendFile(path.join(__dirname, 'views', 'index.html')); }); -app.get('/new-page(.html)?', (req, res) => { +app.get('/new-page{.html}', (req, res) => { res.sendFile(path.join(__dirname, 'views', 'new-page.html')); }); -app.get('/old-page(.html)?', (req, res) => { +app.get('/old-page{.html}', (req, res) => { res.redirect(301, '/new-page.html'); //302 by default }); // Route handlers -app.get('/hello(.html)?', (req, res, next) => { +app.get('/hello{.html}', (req, res, next) => { console.log('attempted to load hello.html'); next() }, (req, res) => { @@ -72,9 +72,9 @@ const three = (req, res) => { res.send('Finished!'); } -app.get('/chain(.html)?', [one, two, three]); +app.get('/chain{.html}', [one, two, three]); -app.all('*', (req, res) => { +app.all('*name', (req, res) => { res.status(404); if (req.accepts('html')) { res.sendFile(path.join(__dirname, 'views', '404.html')); @@ -87,4 +87,4 @@ app.all('*', (req, res) => { app.use(errorHandler); -app.listen(PORT, () => console.log(`Server running on port ${PORT}`)); \ No newline at end of file +app.listen(PORT, () => console.log(`Server running on port ${PORT}`));