mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
JS: add StringOps::StartsWith and StringOps::Includes
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
| tst.js:5:9:5:23 | A.startsWith(B) | tst.js:5:9:5:9 | A | tst.js:5:22:5:22 | B | true |
|
||||
| tst.js:6:9:6:26 | _.startsWith(A, B) | tst.js:6:22:6:22 | A | tst.js:6:25:6:25 | B | true |
|
||||
| tst.js:7:9:7:26 | R.startsWith(A, B) | tst.js:7:22:7:22 | A | tst.js:7:25:7:25 | B | true |
|
||||
| tst.js:8:9:8:26 | A.indexOf(B) === 0 | tst.js:8:9:8:9 | A | tst.js:8:19:8:19 | B | true |
|
||||
| tst.js:9:9:9:26 | A.indexOf(B) !== 0 | tst.js:9:9:9:9 | A | tst.js:9:19:9:19 | B | false |
|
||||
| tst.js:10:9:10:26 | 0 !== A.indexOf(B) | tst.js:10:15:10:15 | A | tst.js:10:25:10:25 | B | false |
|
||||
| tst.js:11:9:11:25 | 0 != A.indexOf(B) | tst.js:11:14:11:14 | A | tst.js:11:24:11:24 | B | false |
|
||||
| tst.js:12:9:12:20 | A.indexOf(B) | tst.js:12:9:12:9 | A | tst.js:12:19:12:19 | B | false |
|
||||
| tst.js:13:10:13:21 | A.indexOf(B) | tst.js:13:10:13:10 | A | tst.js:13:20:13:20 | B | false |
|
||||
| tst.js:14:11:14:22 | A.indexOf(B) | tst.js:14:11:14:11 | A | tst.js:14:21:14:21 | B | false |
|
||||
@@ -0,0 +1,4 @@
|
||||
import javascript
|
||||
|
||||
from StringOps::StartsWith check
|
||||
select check, check.getBaseString(), check.getSubstring(), check.getPolarity()
|
||||
25
javascript/ql/test/library-tests/StringOps/StartsWith/tst.js
Normal file
25
javascript/ql/test/library-tests/StringOps/StartsWith/tst.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import * as _ from 'lodash';
|
||||
import * as R from 'ramda';
|
||||
|
||||
function f(A, B) {
|
||||
if (A.startsWith(B)) {}
|
||||
if (_.startsWith(A, B)) {}
|
||||
if (R.startsWith(A, B)) {}
|
||||
if (A.indexOf(B) === 0) {}
|
||||
if (A.indexOf(B) !== 0) {}
|
||||
if (0 !== A.indexOf(B)) {}
|
||||
if (0 != A.indexOf(B)) {}
|
||||
if (A.indexOf(B)) {} // !startsWith
|
||||
if (!A.indexOf(B)) {} // startsWith
|
||||
if (!!A.indexOf(B)) {} // !startsWith
|
||||
|
||||
// non-examples
|
||||
if (_.startsWith(A, B, 2)) {}
|
||||
if (A.indexOf(B) >= 0) {}
|
||||
if (A.indexOf(B) === 1) {}
|
||||
if (A.indexOf(B) === A.indexOf(B)) {}
|
||||
if (A.indexOf(B) !== -1) {}
|
||||
if (A.indexOf(B, 2) === 0) {}
|
||||
if (A.indexOf(B, 2)) {}
|
||||
if (~A.indexOf(B)) {} // checks for existence, not startsWith
|
||||
}
|
||||
Reference in New Issue
Block a user