Skip to content

Commit 6e1711e

Browse files
committedAug 3, 2021
matchRecursive: make global non-sticky match with valueNames return an empty array if no matches found
1 parent bf480ec commit 6e1711e

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed
 

‎src/addons/matchrecursive.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export default (XRegExp) => {
238238
}
239239
}
240240

241-
if (global && !sticky && vN && vN[0] && str.length > lastOuterEnd) {
241+
if (global && output.length > 0 && !sticky && vN && vN[0] && str.length > lastOuterEnd) {
Has conversations. Original line has conversations.
242242
output.push(row(vN[0], str.slice(lastOuterEnd), lastOuterEnd, str.length));
243243
}
244244

‎tests/spec/s-addons-matchrecursive.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,11 @@ describe('XRegExp.matchRecursive addon:', function() {
155155
valueNames: ['between', 'left', 'match', 'right']
156156
})
157157
).toEqual([]);
158-
// TODO: Change behavior to match test (don't return `between` value with full string)
159-
// expect(
160-
// XRegExp.matchRecursive('.', '<', '>', 'g', {
161-
// valueNames: ['between', 'left', 'match', 'right']
162-
// })
163-
// ).toEqual([]);
158+
expect(
159+
XRegExp.matchRecursive('.', '<', '>', 'g', {
160+
valueNames: ['between', 'left', 'match', 'right']
161+
})
162+
).toEqual([]);
164163
});
165164

166165
});

0 commit comments

Comments
 (0)
Please sign in to comment.