Skip to content

Commit

Permalink
Remove url.parse (#148)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mhornbacher authored Apr 5, 2024
1 parent a21ec7f commit 4a32df2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/playground/basic/server.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const http = require('http')
const url = require('url')
const { URL } = require('url')

const port = 8080

const server = http.createServer((req, res) => {
const urlObject = url.parse(req.url)
const { pathname } = urlObject
const { pathname } = new URL(req.url)

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

0 comments on commit 4a32df2

Please sign in to comment.