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

Skip to content

Commit 4c25d84

Browse files
committed
JS: Fix and expand test cases
1 parent 9928762 commit 4c25d84

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • javascript/ql/test/query-tests/RegExp/RegExpAlwaysMatches

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function optionalPrefix(x) {
33
}
44

55
function mandatoryPrefix(x) {
6-
return /^https:/.test(x); // NOT OK
6+
return /^https:/.test(x); // OK
77
}
88

99
function httpOrHttps(x) {
@@ -65,3 +65,11 @@ function search2(x) {
6565
function lookahead(x) {
6666
return /(?!x)/.search(x); // OK
6767
}
68+
69+
function searchPrefix(x) {
70+
return /^foo?/.search(x); // NOT OK - `foo?` does not affect the returned index
71+
}
72+
73+
function searchSuffix(x) {
74+
return /foo?$/.search(x); // OK - `foo?` affects the returned index
75+
}

0 commit comments

Comments
 (0)