Skip to content

Commit 7cb962a

Browse files
authored
feat: Add regex option u for unicode support in Parse.Query.matches for MongoDB (#9867)
1 parent f755a5d commit 7cb962a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

spec/ParseQuery.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,6 +2113,16 @@ describe('Parse.Query testing', () => {
21132113
.then(done);
21142114
});
21152115

2116+
it_id('351f57a8-e00a-4da2-887d-6e25c9e359fc')(it)('regex with unicode option', async function () {
2117+
const thing = new TestObject();
2118+
thing.set('myString', 'hello 世界');
2119+
await Parse.Object.saveAll([thing]);
2120+
const query = new Parse.Query(TestObject);
2121+
query.matches('myString', '世界', 'u');
2122+
const results = await query.find();
2123+
equal(results.length, 1);
2124+
});
2125+
21162126
it_id('823852f6-1de5-45ba-a2b9-ed952fcc6012')(it)('Use a regex that requires all modifiers', function (done) {
21172127
const thing = new TestObject();
21182128
thing.set('myString', 'PArSe\nCom');

src/Controllers/DatabaseController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const validateQuery = (
111111
Object.keys(query).forEach(key => {
112112
if (query && query[key] && query[key].$regex) {
113113
if (typeof query[key].$options === 'string') {
114-
if (!query[key].$options.match(/^[imxs]+$/)) {
114+
if (!query[key].$options.match(/^[imxsu]+$/)) {
115115
throw new Parse.Error(
116116
Parse.Error.INVALID_QUERY,
117117
`Bad $options value for query: ${query[key].$options}`

0 commit comments

Comments
 (0)