Browse Source

use strict for ecmascript 6 syntax, fix typos

pull/942/head
Lily He 7 years ago
parent
commit
a27ac0fc88
  1. 8
      sanitizer/sanitizeAll.js
  2. 2
      test/unit/sanitizer/nearby.js
  3. 2
      test/unit/sanitizer/place.js

8
sanitizer/sanitizeAll.js

@ -1,3 +1,5 @@
'use strict';
const async = require('async');
function sanitize( req, sanitizers, cb ){
@ -12,7 +14,7 @@ function sanitize( req, sanitizers, cb ){
// (in this case from the GET querystring params)
const params = req.query || {};
for (var s in sanitizers) {
for (let s in sanitizers) {
var sanity = sanitizers[s].sanitize( params, req.clean );
// if errors occurred then set them
@ -37,11 +39,11 @@ function checkParameters(req, sanitizers, cb) {
const params = req.query || {};
const goodParameters = {};
for (var s in sanitizers) {
for (let s in sanitizers) {
// checks if there is a function that returns valid params
if (typeof sanitizers[s].expected === 'function'){
/** func returns {array} ex: [{ name: 'text' }, { name: 'parsed_text' }] */
/** func returns {array} ex: [{ name: 'text' }] */
for (let t in sanitizers[s].expected()) {
/** {object} prop */
const prop = sanitizers[s].expected()[t];

2
test/unit/sanitizer/nearby.js

@ -18,7 +18,7 @@ module.exports.tests = {};
module.exports.tests.interface = function(test, common) {
test('sanitize interface', function(t) {
t.equal(typeof sanitize, 'function', 'sanitize is a function');
t.equal(sanitize.length, 3, 'sanitize interface takes one argument: req');
t.equal(sanitize.length, 3, 'sanitize interface takes three args');
t.end();
});
test('middleware interface', function(t) {

2
test/unit/sanitizer/place.js

@ -10,7 +10,7 @@ module.exports.tests = {};
module.exports.tests.interface = function(test, common) {
test('sanitize interface', function(t) {
t.equal(typeof sanitize, 'function', 'sanitize is a function');
t.equal(sanitize.length, 3, 'sanitize interface takes one arg: req');
t.equal(sanitize.length, 3, 'sanitize interface takes three args');
t.end();
});
test('middleware interface', function(t) {

Loading…
Cancel
Save