Skip to content

Commit 4a32df2

Browse files
authored
Remove url.parse (#148)
This handles the following deprecation in NodeJS by using the URL class rather than the global `parse` method which both have the `pathname` attribute which is what is required here. [DEP0169] DeprecationWarning: url.parse() behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for url.parse() vulnerabilities.
1 parent a21ec7f commit 4a32df2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

packages/playground/basic/server.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const http = require('http')
2-
const url = require('url')
2+
const { URL } = require('url')
33

44
const port = 8080
55

66
const server = http.createServer((req, res) => {
7-
const urlObject = url.parse(req.url)
8-
const { pathname } = urlObject
7+
const { pathname } = new URL(req.url)
98

109
// api开头的是API请求
1110
if (pathname.startsWith('/api')) {

0 commit comments

Comments
 (0)