Skip to content

Commit

Permalink
🐛 Do not add a g flag to regex if it already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
steelbrain committed Jan 22, 2016
1 parent e79ac34 commit b709688
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ function parse(data, regex) {
}

const options = assign({ flags: '' }, opts);
options.flags += 'g';
if (options.flags.indexOf('g') === -1) {
options.flags += 'g';
}

const messages = [];
const compiledRegexp = NamedRegexp(regex, options.flags);
Expand Down
4 changes: 3 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ export function parse(data, regex, opts = {}) {
}

const options = assign({flags: ''}, opts)
options.flags += 'g'
if (options.flags.indexOf('g') === -1) {
options.flags += 'g'
}

const messages = []
const compiledRegexp = NamedRegexp(regex, options.flags)
Expand Down

0 comments on commit b709688

Please sign in to comment.