Skip to content

Commit d72072b

Browse files
committed
Fix patchLokiOps breaking if the passed regex isn't a string
1 parent 8785aee commit d72072b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/common/_connect.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ module.exports = function (config) {
8787
// https://github.com/screeps/backend-local/blob/7520c8c7e6a443ad955d25e064dbd151a909d8cb/lib/strongholds.js#L132
8888
//
8989
// ignore properly escaped sector regex queries
90-
} else if (v.match(/\^[EW]\d*\\d[NS]\d*\\d\$/g) === null && v.match(/\^\[[EW]{2}\]\\d\*5\[[NS]{2}\]\\d\*5\$/g) === null) {
90+
} else if (typeof v === 'string' && v.match(/\^[EW]\d*\\d[NS]\d*\\d\$/g) === null && v.match(/\^\[[EW]{2}\]\\d\*5\[[NS]{2}\]\\d\*5\$/g) === null) {
9191
// default regex escape fix for loki regex queries to work with mongo regex queries
9292
query.$regex = v.replace(/\\{1,2}/g, '\\\\')
93+
} else {
94+
query.$regex = v
9395
}
9496
}
9597
if (typeof v === 'object') {

0 commit comments

Comments
 (0)