http-party / node-http-proxy

A full-featured http proxy for node.js
https://github.com/http-party/node-http-proxy
Other
13.83k stars 1.97k forks source link

util._extend is deprecated #1674

Open pmcelhaney opened 3 weeks ago

pmcelhaney commented 3 weeks ago

Hi! šŸ‘‹

Firstly, thanks for your work on this project! šŸ™‚

Today I used patch-package to patch http-proxy@1.18.1 for the project I'm working on.

Node 22 reports:

(node:37843) [DEP0060] DeprecationWarning: The util._extend API is deprecated. Please use Object.assign() instead.

Here is the diff that solved my problem:

diff --git a/node_modules/http-proxy/lib/http-proxy/common.js b/node_modules/http-proxy/lib/http-proxy/common.js
index 6513e81..0555e80 100644
--- a/node_modules/http-proxy/lib/http-proxy/common.js
+++ b/node_modules/http-proxy/lib/http-proxy/common.js
@@ -1,6 +1,6 @@
 var common   = exports,
     url      = require('url'),
-    extend   = require('util')._extend,
+    extend   = Object.assign,
     required = require('requires-port');

 var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i,
diff --git a/node_modules/http-proxy/lib/http-proxy/index.js b/node_modules/http-proxy/lib/http-proxy/index.js
index 977a4b3..739409c 100644
--- a/node_modules/http-proxy/lib/http-proxy/index.js
+++ b/node_modules/http-proxy/lib/http-proxy/index.js
@@ -1,5 +1,5 @@
 var httpProxy = module.exports,
-    extend    = require('util')._extend,
+    extend    = Object.assign,
     parse_url = require('url').parse,
     EE3       = require('eventemitter3'),
     http      = require('http'),

This issue body was partially generated by patch-package.

pmcelhaney commented 3 weeks ago

There's already a PR: https://github.com/http-party/node-http-proxy/pull/1666