util._extend() is depracatory

Open Beginner friendly
#1,719 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Quiet
Tech stack
javascript, node.js
Domain
api, backend

Research direction

Update lib/http-proxy/index.js, where util._extend is required and used to copy proxy options. Compare the provided diff with the surrounding request-option handling, then run the existing test suite to confirm the proxy behavior is unchanged and the deprecated utility is no longer used.

Written by the indexing model from the issue text.

Description

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.

Here is the diff that solved my problem:

diff --git a/node_modules/http-proxy/lib/http-proxy/index.js b/node_modules/http-proxy/lib/http-proxy/index.js
index 977a4b3..88b2d0f 100644
--- a/node_modules/http-proxy/lib/http-proxy/index.js
+++ b/node_modules/http-proxy/lib/http-proxy/index.js
@@ -1,5 +1,4 @@
 var httpProxy = module.exports,
-    extend    = require('util')._extend,
     parse_url = require('url').parse,
     EE3       = require('eventemitter3'),
     http      = require('http'),
@@ -47,9 +46,9 @@ function createRightProxy(type) {
         args[cntr] !== res
       ) {
         //Copy global options
-        requestOptions = extend({}, options);
+        requestOptions = Object.assign({}, options);
         //Overwrite with request options
-        extend(requestOptions, args[cntr]);
+        Object.assign(requestOptions, args[cntr]);
 
         cntr--;
       }

This issue body was partially generated by patch-package.

Dominant language
JavaScript
Stars
14.1k
Forks
2k
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from http-party/node-http-proxy

All issues in http-party/node-http-proxy

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.