Skip to content

Commit ca65c67

Browse files
committed
Only treat RegExp instances as regular expressions
This affects matchReplaceBody and admin server CORS configuration. If you previously passed something very regex-like but not actually a regex (this is a very niche scenario) then it was handled as a regex. Now we only actually use real regex instances, simplifying the code & logic.
1 parent 4b9e6f6 commit ca65c67

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/admin/admin-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async function strictOriginMatch(
8888
return expectedOrigin === origin;
8989
}
9090

91-
if (_.isRegExp(expectedOrigin)) {
91+
if (expectedOrigin instanceof RegExp) {
9292
return !!origin.match(expectedOrigin);
9393
}
9494

src/rules/requests/request-step-definitions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ export class PassThroughStep extends Serializable implements RequestStepDefiniti
951951
matchReplaceBody: !!this.transformRequest?.matchReplaceBody
952952
? this.transformRequest.matchReplaceBody.map(([match, result]) =>
953953
[
954-
_.isRegExp(match)
954+
match instanceof RegExp
955955
? { regexSource: match.source, flags: match.flags }
956956
: match,
957957
result
@@ -981,7 +981,7 @@ export class PassThroughStep extends Serializable implements RequestStepDefiniti
981981
matchReplaceBody: !!this.transformResponse?.matchReplaceBody
982982
? this.transformResponse.matchReplaceBody.map(([match, result]) =>
983983
[
984-
_.isRegExp(match)
984+
match instanceof RegExp
985985
? { regexSource: match.source, flags: match.flags }
986986
: match,
987987
result

0 commit comments

Comments
 (0)