JS: remove emptiness checks from the type confusion x.length sinks

This commit is contained in:
Esben Sparre Andreasen
2018-08-22 13:20:52 +02:00
parent 44ae7b68f0
commit fef257b1ec
3 changed files with 35 additions and 1 deletions

View File

@@ -50,3 +50,21 @@ express().get('/some/path/:foo', function(req, res) {
var foo = req.params.foo;
foo.indexOf(); // OK
});
express().get('/some/path/:foo', function(req, res) {
if (req.query.path.length) {} // OK
req.query.path.length == 0; // OK
!req.query.path.length == 0; // OK
});
express().get('/some/path/:foo', function(req, res) {
let p = req.query.path;
if (typeof p !== 'string') {
return;
}
while (p.length) { // OK
p = p.substr(1);
}
});