Skip to content

Commit fd8be9f

Browse files
committed
feat(util): add validation arguments to matchCaptureGroupAll
1 parent 40c9381 commit fd8be9f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/util/match-index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// LICENSE : MIT
22
"use strict";
3-
4-
var flagsGetter = require('regexp.prototype.flags');
3+
const flagsGetter = require('regexp.prototype.flags');
4+
const assert = require("assert");
55
/**
66
* @typedef {Object} MatchCaptureGroup
77
* @property {string} text - text is matched texts
88
* @property {number} index - index is start of match
99
*/
1010
export function matchCaptureGroupAll(text, regExp) {
11+
const source = regExp.source;
12+
assert(source.indexOf("(") >= 0, "RegExp should contain capture group at least one");
1113
const all = matchAll(text, regExp);
1214
const captureGroups = [];
1315
all.forEach(match => {

0 commit comments

Comments
 (0)