Skip to content

Commit ff5da2b

Browse files
committed
Remove deprecated node:url
1 parent 1c3f21e commit ff5da2b

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

JavaScript/server.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const http = require('node:http');
4-
const url = require('node:url');
54

65
const routes = {
76
'/': (request, callback) => {
@@ -27,13 +26,7 @@ const routes = {
2726
};
2827

2928
const server = http.createServer((req, res) => {
30-
const parsedUrl = url.parse(req.url);
31-
let path = parsedUrl.pathname;
32-
if (path.endsWith('/') && path.length > 1) {
33-
path = path.slice(0, -1);
34-
}
35-
36-
const handler = routes[path];
29+
const handler = routes[req.url];
3730
if (!handler) {
3831
res.writeHead(404);
3932
res.end('Not found');

0 commit comments

Comments
 (0)