Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d53416

Browse files
committed
JS: Add test for empty regex
1 parent 9f6e048 commit 2d53416

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

javascript/ql/test/query-tests/RegExp/RegExpAlwaysMatches/RegExpAlwaysMatches.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
| tst.js:22:11:22:34 | ^(?:https?:\|ftp:\|file:)? | This regular expression always matches when used in a test $@, as it can match an empty substring. | tst.js:22:10:22:43 | /^(?:ht ... test(x) | here |
44
| tst.js:30:11:30:20 | (foo\|bar)? | This regular expression always matches when used in a test $@, as it can match an empty substring. | tst.js:30:10:30:29 | /(foo\|bar)?/.test(x) | here |
55
| tst.js:34:21:34:26 | (baz)? | This regular expression always matches when used in a test $@, as it can match an empty substring. | tst.js:34:10:34:35 | /^foo\|b ... test(x) | here |
6+
| tst.js:86:22:86:21 | | This regular expression always matches when used in a test $@, as it can match an empty substring. | tst.js:86:10:86:31 | new Reg ... test(x) | here |

javascript/ql/test/query-tests/RegExp/RegExpAlwaysMatches/tst.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@ function wordBoundary(x) {
8181
function nonWordBoundary(x) {
8282
return /\B/.test(x); // OK - some strings don't have non-word boundaries
8383
}
84+
85+
function emptyRegex(x) {
86+
return new RegExp("").test(x); // NOT OK
87+
}

0 commit comments

Comments
 (0)