From 51cd442a95ac24987601e4b8217584704a4febec Mon Sep 17 00:00:00 2001 From: Steven Chim <655241+chimurai@users.noreply.github.com> Date: Sat, 31 Aug 2024 23:47:03 +0200 Subject: [PATCH] refactor(dependency): replace is-plain-obj with is-plain-object (#1031) --- CHANGELOG.md | 4 ++++ package.json | 2 +- src/path-rewriter.ts | 6 +++--- src/router.ts | 4 ++-- yarn.lock | 8 ++++---- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa751597..1618322b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## next + +- refactor(dependency): replace is-plain-obj with is-plain-object + ## [v3.0.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v3.0.1) - fix(type): fix RequestHandler return type ([#980](https://github.com/chimurai/http-proxy-middleware/pull/980)) diff --git a/package.json b/package.json index ec58b8c1..c50b1bf7 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "debug": "^4.3.6", "http-proxy": "^1.18.1", "is-glob": "^4.0.3", - "is-plain-obj": "^3.0.0", + "is-plain-object": "^5.0.0", "micromatch": "^4.0.8" }, "engines": { diff --git a/src/path-rewriter.ts b/src/path-rewriter.ts index 14912dad..a80345ee 100644 --- a/src/path-rewriter.ts +++ b/src/path-rewriter.ts @@ -1,4 +1,4 @@ -import isPlainObj = require('is-plain-obj'); +import { isPlainObject } from 'is-plain-object'; import { ERRORS } from './errors'; import { Debug } from './debug'; @@ -45,7 +45,7 @@ export function createPathRewriter(rewriteConfig) { function isValidRewriteConfig(rewriteConfig) { if (typeof rewriteConfig === 'function') { return true; - } else if (isPlainObj(rewriteConfig)) { + } else if (isPlainObject(rewriteConfig)) { return Object.keys(rewriteConfig).length !== 0; } else if (rewriteConfig === undefined || rewriteConfig === null) { return false; @@ -57,7 +57,7 @@ function isValidRewriteConfig(rewriteConfig) { function parsePathRewriteRules(rewriteConfig: Record) { const rules: RewriteRule[] = []; - if (isPlainObj(rewriteConfig)) { + if (isPlainObject(rewriteConfig)) { for (const [key, value] of Object.entries(rewriteConfig)) { rules.push({ regex: new RegExp(key), diff --git a/src/router.ts b/src/router.ts index 09e91f29..a641b8a6 100644 --- a/src/router.ts +++ b/src/router.ts @@ -1,4 +1,4 @@ -import isPlainObj = require('is-plain-obj'); +import { isPlainObject } from 'is-plain-object'; import { Debug } from './debug'; const debug = Debug.extend('router'); @@ -7,7 +7,7 @@ export async function getTarget(req, config) { let newTarget; const router = config.router; - if (isPlainObj(router)) { + if (isPlainObject(router)) { newTarget = getTargetFromProxyTable(req, router); } else if (typeof router === 'function') { newTarget = await router(req); diff --git a/yarn.lock b/yarn.lock index c4fb3251..7db7f93a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2959,10 +2959,10 @@ is-path-inside@^3.0.3: resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== -is-plain-obj@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-3.0.0.tgz#af6f2ea14ac5a646183a5bbdb5baabbc156ad9d7" - integrity sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA== +is-plain-object@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== is-stream@^2.0.0: version "2.0.1"