From fb12b8e75e8244915502dd3be73f5cfff2f22253 Mon Sep 17 00:00:00 2001 From: Justin Dalrymple Date: Wed, 11 Oct 2023 16:19:44 -0400 Subject: [PATCH] Using browser friendly glob matcher --- packages/requester-utils/package.json | 2 +- packages/requester-utils/src/RequesterUtils.ts | 4 ++-- yarn.lock | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/requester-utils/package.json b/packages/requester-utils/package.json index 96078604c..2c2a1de4b 100644 --- a/packages/requester-utils/package.json +++ b/packages/requester-utils/package.json @@ -52,7 +52,7 @@ }, "dependencies": { "async-sema": "^3.1.1", - "micromatch": "^4.0.5", + "picomatch-browser": "^2.2.6", "qs": "^6.11.2", "xcase": "^2.0.1" }, diff --git a/packages/requester-utils/src/RequesterUtils.ts b/packages/requester-utils/src/RequesterUtils.ts index 05d570e59..b5d9c42f1 100644 --- a/packages/requester-utils/src/RequesterUtils.ts +++ b/packages/requester-utils/src/RequesterUtils.ts @@ -1,7 +1,7 @@ import { stringify } from 'qs'; import { decamelizeKeys } from 'xcase'; import { RateLimit } from 'async-sema'; -import micromatch from 'micromatch'; +import { isMatch as isGlobMatch } from 'picomatch-browser'; // Types export type RateLimiters = Record< @@ -225,7 +225,7 @@ export function getMatchingRateLimiter( method: string = 'GET', ): () => Promise { const sortedEndpoints = Object.keys(rateLimiters).sort().reverse(); - const match = sortedEndpoints.find((ep) => micromatch.isMatch(endpoint, ep)); + const match = sortedEndpoints.find((ep) => isGlobMatch(endpoint, ep)); const rateLimitConfig = match && rateLimiters[match]; if (rateLimitConfig && typeof rateLimitConfig !== 'object') { diff --git a/yarn.lock b/yarn.lock index ae3531c9f..b0780417e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1058,7 +1058,7 @@ __metadata: dependencies: "@types/node": ^20.4.0 async-sema: ^3.1.1 - micromatch: ^4.0.5 + picomatch-browser: ^2.2.6 qs: ^6.11.2 tsup: ^7.1.0 typescript: ^5.1.6 @@ -7981,7 +7981,7 @@ __metadata: languageName: node linkType: hard -"micromatch@npm:4.0.5, micromatch@npm:^4.0.4, micromatch@npm:^4.0.5": +"micromatch@npm:4.0.5, micromatch@npm:^4.0.4": version: 4.0.5 resolution: "micromatch@npm:4.0.5" dependencies: @@ -9270,6 +9270,13 @@ __metadata: languageName: node linkType: hard +"picomatch-browser@npm:^2.2.6": + version: 2.2.6 + resolution: "picomatch-browser@npm:2.2.6" + checksum: 946c50a8654da43167a0f9a90dd0b50f3d4e830ee71c0926ee9052d7e6f40d8907deaafba19cea71b97207b4aaa52c245335e4cd5bbaf78fe2ba567cd0c341fa + languageName: node + linkType: hard + "picomatch@npm:^2.0.4, picomatch@npm:^2.2.1, picomatch@npm:^2.2.3, picomatch@npm:^2.3.1": version: 2.3.1 resolution: "picomatch@npm:2.3.1"