Skip to content

Commit 462f5f2

Browse files
committed
Use if instead of switch
1 parent 1b6bd21 commit 462f5f2

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

Lesson03/exercise_004/index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,12 @@ function handleRequest(request, response) {
4747
const requestUrl = url.parse(request.url);
4848
const pathname = requestUrl.pathname;
4949

50-
switch(pathname) {
51-
case '/':
52-
case '/index.html':
53-
handleProductsPage(requestUrl, response);
54-
return;
55-
default:
56-
handleStaticFile(pathname, response);
57-
return;
50+
if (pathname == '/' || pathname == '/index.html') {
51+
handleProductsPage(requestUrl, response);
52+
return;
5853
}
54+
55+
handleStaticFile(pathname, response);
5956
}
6057

6158
function initializeServer() {

0 commit comments

Comments
 (0)