8000 Remove deprecated node:url · HowProgrammingWorks/Generator@5eb1b2d · GitHub
[go: up one dir, main page]

Skip to content

Commit 5eb1b2d

Browse files
committed
Remove deprecated node:url
1 parent 6848249 commit 5eb1b2d

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

JavaScript/helpers/server.js

Lines changed: 1 addition & 9 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,19 +26,12 @@ 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');
4033
return;
4134
}
42-
4335
handler(req, (result) => {
4436
const json = JSON.stringify(result);
4537
res.writeHead(200, { 'Content-Type': 'application/json' });

0 commit comments

Comments
 (0)
0