Skip to content

Commit

Permalink
fix, add use first flags property, and support dotAll flag (ramda#3158)
Browse files Browse the repository at this point in the history
* fix, add use first flags property, and support dotAll flag

* add dotAll flag test case

* move eslint-env comment to top

* remove eslint-env comment
  • Loading branch information
HoKangInfo authored Jan 22, 2022
1 parent 7277709 commit 1bd60c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 6 additions & 5 deletions source/internal/_cloneRegExp.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export default function _cloneRegExp(pattern) {
return new RegExp(pattern.source, (pattern.global ? 'g' : '') +
(pattern.ignoreCase ? 'i' : '') +
(pattern.multiline ? 'm' : '') +
(pattern.sticky ? 'y' : '') +
(pattern.unicode ? 'u' : ''));
return new RegExp(pattern.source, (pattern.flags ? pattern.flags : (pattern.global ? 'g' : '') +
(pattern.ignoreCase ? 'i' : '') +
(pattern.multiline ? 'm' : '') +
(pattern.sticky ? 'y' : '') +
(pattern.unicode ? 'u' : '') +
(pattern.dotAll ? 's' : '')));
}
3 changes: 3 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ var eq = require('./shared/eq.js');


describe('test', function() {
it('returns true if string matches dotAll pattern', function() {
eq(R.test(/x.*z/s, 'x.\nyz'), true);
});

it('returns true if string matches pattern', function() {
eq(R.test(/^x/, 'xyz'), true);
Expand Down

0 comments on commit 1bd60c5

Please sign in to comment.