Fix typo in wrapRegExp helper (#9726)

This commit is contained in:
Nicolò Ribaudo 2019-03-21 00:18:43 +01:00 committed by GitHub
parent ab41cb2cda
commit bf94bb9d43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -1870,7 +1870,7 @@ helpers.wrapRegExp = helper("7.2.6")`
// but in that case Babel doesn't add the wrapper anyway.
var g = _groups.get(re);
return Object.keys(groups).reduce(function(groups, name) {
return Object.keys(g).reduce(function(groups, name) {
groups[name] = result[g[name]];
return groups;
}, Object.create(null));

View File

@ -0,0 +1,10 @@
const regex1 = /(?<alpha>\w+):(?<bravo>\d+)/;
const regex2 = /(?<alpha>\w+):(?<bravo>[a-z]+):(?<charlie>\w+)/;
const result = regex2.exec("foo:abc:bar");
expect(result.groups).toEqual({
alpha: "foo",
bravo: "abc",
charlie: "bar",
});