Browse Source

Remove unused file: sanitiser/_source.js

It was replaced by the dual purpose sanitiser/_targets.js
pull/407/head
Julian Simioni 9 years ago
parent
commit
9ec2cd41d9
  1. 46
      sanitiser/_source.js

46
sanitiser/_source.js

@ -1,46 +0,0 @@
var _ = require('lodash'),
check = require('check-types'),
sources_map = require( '../query/sources' );
var ALL_SOURCES = Object.keys(sources_map),
ALL_SOURCES_JOINED = ALL_SOURCES.join(',');
function sanitize( raw, clean ) {
// error & warning messages
var messages = { errors: [], warnings: [] };
// init clean.types (if not already init)
clean.types = clean.types || {};
// default case (no layers specified in GET params)
// don't even set the from_layers key in this case
if( check.nonEmptyString( raw.source ) ){
var sources = raw.source.split(',');
var invalid_sources = sources.filter(function(source) {
return !_.includes( ALL_SOURCES, source );
});
if( invalid_sources.length > 0 ){
invalid_sources.forEach( function( invalid ){
messages.errors.push('\'' + invalid + '\' is an invalid source parameter. Valid options: ' + ALL_SOURCES_JOINED);
});
}
else {
var types = sources.reduce(function(acc, source) {
return acc.concat(sources_map[source]);
}, []);
clean.types.from_source = types;
}
}
return messages;
}
module.exports = sanitize;
Loading…
Cancel
Save