Skip to content

Commit

Permalink
Using browser friendly glob matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalrymple committed Oct 11, 2023
1 parent b6ac7ea commit fb12b8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/requester-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/requester-utils/src/RequesterUtils.ts
Original file line number Diff line number Diff line change
@@ -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<
Expand Down Expand Up @@ -225,7 +225,7 @@ export function getMatchingRateLimiter(
method: string = 'GET',
): () => Promise<void> {
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') {
Expand Down
11 changes: 9 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit fb12b8e

Please sign in to comment.