gulp-webserver
gulp-webserver copied to clipboard
example of dropping `.html` exention?
Could someone provide an example of routing static webpages without their .html
extension please?
I looked at this thread, but I don't quite get it.
Hello @tomByrer, not sure if you still need help with this and I can't say that i've got the prettiest solution for it.
webserver({
middleware: function (req, res, next) {
// Stuff to be ignored
if (req.url.indexOf('assets') >= 0) {
next();
return
}
// If `/` is requested. append index to it
if (req.url === '/') {
req.url = '/index';
}
const url = req.url + '.html';
req.url = url;
next();
}
})