re2 1.19.0 → 1.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/exec.cc +4 -4
- package/lib/match.cc +4 -5
- package/package.json +4 -4
- package/tests/test_exec.js +22 -0
- package/tests/test_match.js +12 -1
package/README.md
CHANGED
|
@@ -353,6 +353,7 @@ console.log('re2_res : ' + re2_res); // prints: re2_res : abc,a,b,c
|
|
|
353
353
|
|
|
354
354
|
## Release history
|
|
355
355
|
|
|
356
|
+
- 1.19.1 *Bugfix: indices for the `d` flag when `lastIndex` is non zero. Bugfix: the match result. Thx, [teebu](https://github.com/teebu).*
|
|
356
357
|
- 1.19.0 *Added `hasIndices` AKA the `d` flag. Thx, [teebu](https://github.com/teebu).*
|
|
357
358
|
- 1.18.3 *Fixed bug with non-matched groups. Thx, [Dan Setterquist](https://github.com/dset).*
|
|
358
359
|
- 1.18.2 *Reference to the binary module by its full name.*
|
package/lib/exec.cc
CHANGED
|
@@ -90,8 +90,8 @@ NAN_METHOD(WrappedRE2::Exec)
|
|
|
90
90
|
if (re2->hasIndices) {
|
|
91
91
|
auto pair = Nan::New<v8::Array>();
|
|
92
92
|
auto offset = data - str.data;
|
|
93
|
-
Nan::Set(pair, 0, Nan::New<v8::Integer>(static_cast<int>(offset)));
|
|
94
|
-
Nan::Set(pair, 1, Nan::New<v8::Integer>(static_cast<int>(offset + item.size())));
|
|
93
|
+
Nan::Set(pair, 0, Nan::New<v8::Integer>(indexOffset + static_cast<int>(offset)));
|
|
94
|
+
Nan::Set(pair, 1, Nan::New<v8::Integer>(indexOffset + static_cast<int>(offset + item.size())));
|
|
95
95
|
Nan::Set(indices, i, pair);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -118,8 +118,8 @@ NAN_METHOD(WrappedRE2::Exec)
|
|
|
118
118
|
auto pair = Nan::New<v8::Array>();
|
|
119
119
|
auto offset = getUtf16Length(str.data + lastIndex, data);
|
|
120
120
|
auto length = getUtf16Length(data, data + item.size());
|
|
121
|
-
Nan::Set(pair, 0, Nan::New<v8::Integer>(static_cast<int>(offset)));
|
|
122
|
-
Nan::Set(pair, 1, Nan::New<v8::Integer>(static_cast<int>(offset + length)));
|
|
121
|
+
Nan::Set(pair, 0, Nan::New<v8::Integer>(indexOffset + static_cast<int>(offset)));
|
|
122
|
+
Nan::Set(pair, 1, Nan::New<v8::Integer>(indexOffset + static_cast<int>(offset + length)));
|
|
123
123
|
Nan::Set(indices, i, pair);
|
|
124
124
|
}
|
|
125
125
|
}
|
package/lib/match.cc
CHANGED
|
@@ -206,11 +206,10 @@ NAN_METHOD(WrappedRE2::Match)
|
|
|
206
206
|
Nan::Set(indices, Nan::New("groups").ToLocalChecked(), Nan::Undefined());
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
Nan::Set(result, Nan::New("indices").ToLocalChecked(), indices);
|
|
209
|
+
if (re2->hasIndices)
|
|
210
|
+
{
|
|
211
|
+
Nan::Set(result, Nan::New("indices").ToLocalChecked(), indices);
|
|
212
|
+
}
|
|
214
213
|
}
|
|
215
214
|
|
|
216
215
|
info.GetReturnValue().Set(result);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "re2",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.1",
|
|
4
4
|
"description": "Bindings for RE2: fast, safe alternative to backtracking regular expression engines.",
|
|
5
5
|
"homepage": "https://github.com/uhop/node-re2",
|
|
6
6
|
"bugs": "https://github.com/uhop/node-re2/issues",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"install-artifact-from-github": "^1.3.3",
|
|
15
15
|
"nan": "^2.17.0",
|
|
16
|
-
"node-gyp": "^9.
|
|
16
|
+
"node-gyp": "^9.4.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/node": "^20.
|
|
19
|
+
"@types/node": "^20.3.1",
|
|
20
20
|
"heya-unit": "^0.3.0",
|
|
21
|
-
"typescript": "^5.
|
|
21
|
+
"typescript": "^5.1.3"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"test": "node tests/tests.js",
|
package/tests/test_exec.js
CHANGED
|
@@ -414,5 +414,27 @@ xy2 (at start of line)
|
|
|
414
414
|
} catch (e) {
|
|
415
415
|
// squelch
|
|
416
416
|
}
|
|
417
|
+
},
|
|
418
|
+
|
|
419
|
+
function test_hasIndexLastIndex(t) {
|
|
420
|
+
'use strict';
|
|
421
|
+
|
|
422
|
+
const re2 = new RE2('a', 'dg');
|
|
423
|
+
|
|
424
|
+
eval(t.TEST('re2.lastIndex === 0'));
|
|
425
|
+
|
|
426
|
+
let result = re2.exec('abca');
|
|
427
|
+
eval(t.TEST('re2.lastIndex === 1'));
|
|
428
|
+
eval(t.TEST('result.index === 0'));
|
|
429
|
+
eval(t.TEST('t.unify(result.indices, [[0, 1]])'));
|
|
430
|
+
|
|
431
|
+
result = re2.exec('abca');
|
|
432
|
+
eval(t.TEST('re2.lastIndex === 4'));
|
|
433
|
+
eval(t.TEST('result.index === 3'));
|
|
434
|
+
eval(t.TEST('t.unify(result.indices, [[3, 4]])'));
|
|
435
|
+
|
|
436
|
+
result = re2.exec('abca');
|
|
437
|
+
eval(t.TEST('re2.lastIndex === 0'));
|
|
438
|
+
eval(t.TEST('result === null'));
|
|
417
439
|
}
|
|
418
440
|
]);
|
package/tests/test_match.js
CHANGED
|
@@ -151,11 +151,22 @@ unit.add(module, [
|
|
|
151
151
|
function test_matchHasIndices(t) {
|
|
152
152
|
'use strict';
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
const re = new RE2('(aa)(?<b>b)?(?<c>ccc)', 'd'),
|
|
155
155
|
str1 = '1aabccc2',
|
|
156
156
|
str2 = '1aaccc2';
|
|
157
157
|
|
|
158
158
|
eval(t.TEST("t.unify(str1.match(re), re.exec(str1))"));
|
|
159
159
|
eval(t.TEST("t.unify(str2.match(re), re.exec(str2))"));
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
function test_matchHasIndicesGlobal(t) {
|
|
163
|
+
'use strict';
|
|
164
|
+
|
|
165
|
+
const re = new RE2('(?<zzz>a)', 'dg'),
|
|
166
|
+
result = 'abca'.match(re);
|
|
167
|
+
|
|
168
|
+
eval(t.TEST("t.unify(result, ['a', 'a'])"));
|
|
169
|
+
eval(t.TEST("!('indices' in result)"));
|
|
170
|
+
eval(t.TEST("!('groups' in result)"));
|
|
160
171
|
}
|
|
161
172
|
]);
|