mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
JS: Fix buggy test cases
This commit is contained in:
@@ -3,4 +3,6 @@
|
|||||||
| 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 |
|
| 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 |
|
||||||
| 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 |
|
| 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 |
|
||||||
| 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 |
|
| 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 |
|
||||||
|
| tst.js:58:20:58:25 | [a-z]* | This regular expression always the matches at index 0 when used $@, as it matches the empty substring. | tst.js:58:10:58:27 | x.search(/[a-z]*/) | here |
|
||||||
|
| tst.js:70:20:70:26 | ^(foo)? | This regular expression always the matches at index 0 when used $@, as it matches the empty substring. | tst.js:70:10:70:28 | x.search(/^(foo)?/) | here |
|
||||||
| 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 |
|
| 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 |
|
||||||
|
|||||||
@@ -55,23 +55,23 @@ function emptyAlt3(x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function search(x) {
|
function search(x) {
|
||||||
return /[a-z]*/.search(x); // NOT OK
|
return x.search(/[a-z]*/); // NOT OK
|
||||||
}
|
}
|
||||||
|
|
||||||
function search2(x) {
|
function search2(x) {
|
||||||
return /[a-z]/.search(x); // OK
|
return x.search(/[a-z]/); // OK
|
||||||
}
|
}
|
||||||
|
|
||||||
function lookahead(x) {
|
function lookahead(x) {
|
||||||
return /(?!x)/.search(x); // OK
|
return x.search(/(?!x)/); // OK
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchPrefix(x) {
|
function searchPrefix(x) {
|
||||||
return /^foo?/.search(x); // NOT OK - `foo?` does not affect the returned index
|
return x.search(/^(foo)?/); // NOT OK - `foo?` does not affect the returned index
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchSuffix(x) {
|
function searchSuffix(x) {
|
||||||
return /foo?$/.search(x); // OK - `foo?` affects the returned index
|
return x.search(/(foo)?$/); // OK - `foo?` affects the returned index
|
||||||
}
|
}
|
||||||
|
|
||||||
function wordBoundary(x) {
|
function wordBoundary(x) {
|
||||||
|
|||||||
Reference in New Issue
Block a user