From f5d840d34c8a030567abf6bd487ceba5ec0500a9 Mon Sep 17 00:00:00 2001 From: Parissai Date: Thu, 29 Mar 2018 12:50:56 +0100 Subject: [PATCH] format router Relates #56 --- src/router.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/router.js b/src/router.js index 4f1fc31..d6cad76 100644 --- a/src/router.js +++ b/src/router.js @@ -1,18 +1,23 @@ -const {handleHome, handleLatest, handleStatic, handleSearch} = require("./handler"); +const { + handleHome, + handleLatest, + handleStatic, + handleSearch +} = require('./handler'); const router = (request, response) => { const url = request.url; - if (url === "/") { + if (url === '/') { handleHome(request, response); - } else if (url === "/latest") { + } else if (url === '/latest') { handleLatest(request, response); - } else if (url.indexOf("public") !== -1) { + } else if (url.indexOf('public') !== -1) { handleStatic(request, response); - } else if (url.startsWith("/search")) { + } else if (url.startsWith('/search')) { handleSearch(request, response); } else { - response.writeHead(404, { "Content-Type": "text/html" }); - response.end("Page not found"); + response.writeHead(404, { 'Content-Type': 'text/html' }); + response.end('Page not found'); } };