ff-stream-web

git clone git://archive.git.mtrnord.blog/MTRNord/ff-stream-web.git
Log | Files | Refs | README | LICENSE

commit b3298559f15d9d8a665c3c90fb016ad3e0509558
parent 2608e1675a267b5d0855c08c5d261e9c12f24480
Author: Konstantin Tarkus <hello@tarkus.me>
Date:   Thu, 11 Dec 2014 11:01:37 +0300

Add 404.html page support to BrowserSync configuration (middleware). Closes #40

Diffstat:
Mgulpfile.js | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js @@ -209,9 +209,14 @@ gulp.task('serve', function(cb) { middleware: function(req, res, cb) { var uri = url.parse(req.url); if (uri.pathname.length > 1 && - path.extname(uri.pathname) === '' && - fs.existsSync(DEST + uri.pathname + '.html')) { - req.url = uri.pathname + '.html' + (uri.search || ''); + uri.pathname.lastIndexOf('/browser-sync/', 0) !== 0 && + !fs.existsSync(DEST + uri.pathname)) { + if (fs.existsSync(DEST + uri.pathname + '.html')) { + req.url = uri.pathname + '.html' + (uri.search || ''); + } else { + res.statusCode = 404; + req.url = '/404.html' + (uri.search || ''); + } } cb(); }