Skip to content

Commit

Permalink
fix: roll back to glob-to-regexp
Browse files Browse the repository at this point in the history
This is because globrex depends on process, which does not exist in the browser
  • Loading branch information
wheresrhys committed Aug 13, 2024
1 parent 515fcfb commit b114124
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 23 deletions.
21 changes: 8 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/eslint__js": "^8.42.3",
"@types/events": "^3.0.3",
"@types/globrex": "^0.1.4",
"@types/node": "^20.14.10",
"@vitest/browser": "^1.1.0",
"@vitest/coverage-istanbul": "^1.1.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
"homepage": "https://github.com/wheresrhys/fetch-mock#readme",
"dependencies": {
"dequal": "^2.0.3",
"globrex": "^0.1.2",
"glob-to-regexp": "^0.4.1",
"is-subset-of": "^3.1.10",
"regexparam": "^3.0.0"
"regexparam": "^3.0.0",
"@types/glob-to-regexp": "^0.4.4"
}
}
7 changes: 3 additions & 4 deletions packages/core/src/Matchers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RouteConfig} from './Route.js';
import { CallLog } from './CallHistory.js';
import glob from 'globrex';
import glob from 'glob-to-regexp';
import * as regexparam from 'regexparam';
import { isSubsetOf } from 'is-subset-of';
import { dequal as isEqual } from 'dequal';
Expand Down Expand Up @@ -44,8 +44,8 @@ const stringMatchers: { [key: string]: UrlMatcherGenerator } = {
url.substr(-targetString.length) === targetString,

glob: (targetString) => {
const urlRX = /** @type {{regex: RegExp}} */ (glob(targetString));
return ({ url }) => urlRX.regex.test(url);
const urlRX = glob(targetString);
return ({ url }) => urlRX.test(url);
},
express: (targetString) => {
const urlRX = regexparam.parse(targetString);
Expand All @@ -56,7 +56,6 @@ const stringMatchers: { [key: string]: UrlMatcherGenerator } = {
return false;
}
vals.shift();
/** @type {Object.<string,string>} */
callLog.expressParams = urlRX.keys.reduce(
(map, paramName, i) =>
vals[i] ? Object.assign(map, { [paramName]: vals[i] }) : map,
Expand Down
3 changes: 2 additions & 1 deletion packages/fetch-mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"homepage": "http://www.wheresrhys.co.uk/fetch-mock",
"dependencies": {
"dequal": "^2.0.3",
"globrex": "^0.1.2",
"glob-to-regexp": "^0.4.1",
"@types/glob-to-regexp": "^0.4.4",
"is-subset": "^0.1.1",
"regexparam": "^3.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/fetch-mock/src/Route/matchers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import glob from 'globrex';
import glob from 'glob-to-regexp';
import * as regexparam from 'regexparam';
import isSubset from 'is-subset';
import { dequal as isEqual } from 'dequal';
Expand All @@ -22,7 +22,7 @@ const stringMatchers = {
),
glob: (targetString) => {
const urlRX = glob(targetString);
return debuggableUrlFunc((url) => urlRX.regex.test(url));
return debuggableUrlFunc((url) => urlRX.test(url));
},
express: (targetString) => {
const urlRX = regexparam.parse(targetString);
Expand Down

0 comments on commit b114124

Please sign in to comment.