Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: transform name capturing regex once #10395

Merged
merged 4 commits into from Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -12,7 +12,7 @@ export default function({ types: t }, options) {
visitor: {
RegExpLiteral(path) {
const node = path.node;
if (node.pattern.indexOf("(?<") === -1) {
if (!/\(\?<(?![=!])/.test(node.pattern)) {
// Return early if there are no named groups.
// The .indexOf check may have false positives (e.g. /\(?</); in
// this case we parse the regex and regexp-tree won't transform it.
Expand Down
@@ -0,0 +1,7 @@
const regex = /(?<=a)(?<a>[a])/

const result = regex.exec("aa");

expect(result.groups).toEqual({
a: "a"
});
@@ -0,0 +1,3 @@
{
"minNodeVersion": "8.0.0"
}