Skip to content

Commit

Permalink
refactor(dependency): replace is-plain-obj with is-plain-object (#1031)
Browse files Browse the repository at this point in the history
  • Loading branch information
chimurai authored Aug 31, 2024
1 parent 1b3817d commit 51cd442
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions src/path-rewriter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isPlainObj = require('is-plain-obj');
import { isPlainObject } from 'is-plain-object';
import { ERRORS } from './errors';
import { Debug } from './debug';

Expand Down Expand Up @@ -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;
Expand All @@ -57,7 +57,7 @@ function isValidRewriteConfig(rewriteConfig) {
function parsePathRewriteRules(rewriteConfig: Record<string, string>) {
const rules: RewriteRule[] = [];

if (isPlainObj(rewriteConfig)) {
if (isPlainObject(rewriteConfig)) {
for (const [key, value] of Object.entries(rewriteConfig)) {
rules.push({
regex: new RegExp(key),
Expand Down
4 changes: 2 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 51cd442

Please sign in to comment.