app.js
function buildOptions(request, callback) {

    let options = {};
    let err = null;

     if (request.payload.html !== undefined) {
        options.html = request.payload.html.trim();
    }

    if (request.payload.baseUrl !== undefined) {
        options.baseUrl = request.payload.baseUrl.trim();
    }

    if (request.payload.filters !== undefined) {
        if (request.payload.filters.indexOf(',') > -1) {
            options.filters = trimArray(request.payload.filters.split(','))
        } else {
            options.filters = trimArray(request.payload.filters)
        }
        if (options.filters.length === 0) {
            delete options.filters;
        }
    }

    if (request.payload.dateFormat !== undefined) {
        options.dateFormat = request.payload.dateFormat;
    }

    if (request.payload.textFormat !== undefined) {
        options.textFormat = request.payload.textFormat;
    }

    if (request.payload.overlappingVersions !== undefined) {
        options.overlappingVersions = request.payload.overlappingVersions
    }

    if (request.payload.impliedPropertiesByVersion !== undefined) {
        options.impliedPropertiesByVersion = request.payload.impliedPropertiesByVersion
    }

    if (request.payload.parseLatLonGeo !== undefined) {
        options.parseLatLonGeo = request.payload.parseLatLonGeo
    }


    if (request.payload.url !== undefined) {

        Request(request.payload.url, function (error, response, body) {

            err = error;
            if(!err && response && response.statusCode === 200){
                options.html = body;
                callback(null, options);
            }else{
                callback(err, null);
            }
        });
    }else{
        callback(err, options);
    }

}
function buildOptions(request, callback) {

    let options = {};
    let err = null;

     if (request.payload.html !== undefined) {
        options.html = request.payload.html.trim();
    }

    if (request.payload.baseUrl !== undefined) {
        options.baseUrl = request.payload.baseUrl.trim();
    }

    if (request.payload.filters !== undefined) {
        if (request.payload.filters.indexOf(',') > -1) {
            options.filters = trimArray(request.payload.filters.split(','))
        } else {
            options.filters = trimArray(request.payload.filters)
        }
        if (options.filters.length === 0) {
            delete options.filters;
        }
    }

    if (request.payload.dateFormat !== undefined) {
        options.dateFormat = request.payload.dateFormat;
    }

    if (request.payload.textFormat !== undefined) {
        options.textFormat = request.payload.textFormat;
    }

    if (request.payload.overlappingVersions !== undefined) {
        options.overlappingVersions = request.payload.overlappingVersions
    }

    if (request.payload.impliedPropertiesByVersion !== undefined) {
        options.impliedPropertiesByVersion = request.payload.impliedPropertiesByVersion
    }

    if (request.payload.parseLatLonGeo !== undefined) {
        options.parseLatLonGeo = request.payload.parseLatLonGeo
    }


    if (request.payload.url !== undefined) {

        Request(request.payload.url, function (error, response, body) {

            err = error;
            if(!err && response && response.statusCode === 200){
                options.html = body;
                callback(null, options);
            }else{
                callback(err, null);
            }
        });
    }else{
        callback(err, options);
    }

}
function buildOptions ( request , callback ) { let options = { } ; let err = null ; if ( request . payload . html !== undefined ) { options . html = request . payload . html . trim ( ) ; } if ( request . payload . baseUrl !== undefined ) { options . baseUrl = request . payload . baseUrl . trim ( ) ; } if ( request . payload . filters !== undefined ) { if ( request . payload . filters . indexOf ( ',' ) > - 1 ) { options . filters = trimArray ( request . payload . filters . split ( ',' ) ) } else { options . filters = trimArray ( request . payload . filters ) } if ( options . filters . length === 0 ) { delete options . filters ; } } if ( request . payload . dateFormat !== undefined ) { options . dateFormat = request . payload . dateFormat ; } if ( request . payload . textFormat !== undefined ) { options . textFormat = request . payload . textFormat ; } if ( request . payload . overlappingVersions !== undefined ) { options . overlappingVersions = request . payload . overlappingVersions } if ( request . payload . impliedPropertiesByVersion !== undefined ) { options . impliedPropertiesByVersion = request . payload . impliedPropertiesByVersion } if ( request . payload . parseLatLonGeo !== undefined ) { options . parseLatLonGeo = request . payload . parseLatLonGeo } if ( request . payload . url !== undefined ) { Request ( request . payload . url , function ( error , response , body ) { err = error ; if ( ! err && response && response . statusCode === 200 ) { options . html = body ; callback ( null , options ) ; } else { callback ( err , null ) ; } } ) ; } else { callback ( err , options ) ; } }
create options from form input
create options from form input