Skip to content

Commit

Permalink
Merge pull request #1588 from pelias/fix-categories-sanitizer
Browse files Browse the repository at this point in the history
Fix category sanitizer for new call format
  • Loading branch information
orangejulius authored Nov 30, 2021
2 parents 3cb2620 + 9b27bb4 commit f1f4c24
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sanitizer/_categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const WARNINGS = {
};

// validate inputs, convert types and apply defaults
function _sanitize (raw, clean, validator) {
function _sanitize (raw, clean, req, validator) {
validator = validator || allValidValidator;

// error & warning messages
Expand Down
2 changes: 1 addition & 1 deletion sanitizer/_geonames_deprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const _ = require('lodash');

const coarse_reverse_message ='coarse /reverse does not support geonames. See https://github.com/pelias/pelias/issues/675 for more info';

function _sanitize( raw, clean, opts ) {
function _sanitize( raw, clean ) {
// error & warning messages
const messages = { errors: [], warnings: [] };

Expand Down
8 changes: 4 additions & 4 deletions test/unit/sanitizer/_categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module.exports.tests.valid_categories = function(test, common) {
clean: { }
};

var messages = sanitizer.sanitize(req.query, req.clean, validCategories);
var messages = sanitizer.sanitize(req.query, req.clean, req, validCategories);

t.deepEqual(req.clean.categories, ['food'], 'categories should contain food');
t.deepEqual(messages.errors, [], 'no error returned');
Expand All @@ -110,7 +110,7 @@ module.exports.tests.valid_categories = function(test, common) {
};
var expectedCategories = ['food', 'health'];

var messages = sanitizer.sanitize(req.query, req.clean, validCategories);
var messages = sanitizer.sanitize(req.query, req.clean, req, validCategories);

t.deepEqual(req.clean.categories, expectedCategories,
'clean.categories should be an array with proper values');
Expand Down Expand Up @@ -145,7 +145,7 @@ module.exports.tests.invalid_categories = function(test, common) {
]
};

var messages = sanitizer.sanitize(req.query, req.clean, validCategories);
var messages = sanitizer.sanitize(req.query, req.clean, req, validCategories);

t.deepEqual(messages, expected_messages, 'error with message returned');
t.deepEqual(req.clean.categories, [], 'empty categories array should be defined');
Expand All @@ -166,7 +166,7 @@ module.exports.tests.invalid_categories = function(test, common) {
]
};

var messages = sanitizer.sanitize(req.query, req.clean, validCategories);
var messages = sanitizer.sanitize(req.query, req.clean, req, validCategories);

t.deepEqual(messages, expected_messages, 'error with message returned');
t.deepEqual(req.clean.categories, [], 'empty categories array should be defined');
Expand Down

0 comments on commit f1f4c24

Please sign in to comment.