index.js
function parseGoogleNewsRSSParams(params) {
    // get params of interest
    var newsType = params.newsType;
    var newsTypeTerms = params.newsTypeTerms;
    // if missing just one parameter flag error as such
    if ((newsType == undefined) && (newsTypeTerms != undefined))
        return parseGoogleNewsRSSParamsErrorHelper('Parameter newsTypeTerms set with no newsType set.');
    if ((newsType != undefined) && (newsTypeTerms == undefined))
        return parseGoogleNewsRSSParamsErrorHelper('Parameter newsType set with no newsTypeTerms set.');
    // if missing both parameters, set to default
    if ((newsType == undefined) && (newsTypeTerms == undefined)) {
        newsType = 'TOPIC';
        newsTypeTerms = 'HEADLINES';
    }
    // fix case parameters
    newsType = newsType.toUpperCase();
    newsTypeTerms = newsTypeTerms.toUpperCase();
    // expand newsType name if needed
    if (newsType == 'T')
        newsType = 'TOPIC';
    if (newsType == 'Q')
        newsType = 'QUERY';
    // if an invalid newsType set flag error as such
    if ((newsType != 'TOPIC') && (newsType != 'QUERY'))
        return parseGoogleNewsRSSParamsErrorHelper('Invalid newsType parameter specified.');
    // if type is topic
    if (newsType == 'TOPIC') {
        // init the short and long term names of the topic type
        var newsTypeTermTopicShort = null;
        var newsTypeTermTopicLong = null;
        // check the term for either short or long name and then set names accordingly
        if ((newsTypeTerms == 'H') || (newsTypeTerms == 'HEADLINES')) {
            newsTypeTermTopicShort = 'H';
            newsTypeTermTopicLong = 'HEADLINES';
        }
        if ((newsTypeTerms == 'N') || (newsTypeTerms == 'NATIONAL')) {
            newsTypeTermTopicShort = 'N';
            newsTypeTermTopicLong = 'NATIONAL';
        }
        if ((newsTypeTerms == 'W') || (newsTypeTerms == 'WORLD')) {
            newsTypeTermTopicShort = 'W';
            newsTypeTermTopicLong = 'WORLD';
        }        
        if ((newsTypeTerms == 'E') || (newsTypeTerms == 'ENTERTAINMENT')) {
            newsTypeTermTopicShort = 'E';
            newsTypeTermTopicLong = 'ENTERTAINMENT';
        }
        if ((newsTypeTerms == 'B') || (newsTypeTerms == 'BUSINESS')) {
            newsTypeTermTopicShort = 'B';
            newsTypeTermTopicLong = 'BUSINESS';
        }         
        if ((newsTypeTerms == 'S') || (newsTypeTerms == 'SPORTS')) {
            newsTypeTermTopicShort = 'S';
            newsTypeTermTopicLong = 'SPORTS';
        }
        if ((newsTypeTerms == 'T') || (newsTypeTerms == 'SCI/TECH')) {
            newsTypeTermTopicShort = 'T';
            newsTypeTermTopicLong = 'SCI/TECH';
        }
        if ((newsTypeTerms == 'TC') || (newsTypeTerms == 'TECHNOLOGY')) {
            newsTypeTermTopicShort = 'TC';
            newsTypeTermTopicLong = 'TECHNOLOGY';
        }
        // if nothing was set it was a bad topic type flag error as such
        if (newsTypeTermTopicShort == null)
            return parseGoogleNewsRSSParamsErrorHelper('Parameter newsTypeTerms is unknown for newsType TOPIC.');
        // build the request URL
        var newsURL = 'https://news.google.com/news?cf=all&hl=en&pz=1&ned=us&topic=' 
                        + newsTypeTermTopicShort.toLowerCase()
                        + '&output=rss';
        // build the return object                
        return {error: false, errorMessage: null,
                type: 'TOPIC', terms: newsTypeTermTopicLong, url: newsURL};
    }
    // if type is query
    if (newsType == 'QUERY') {
        var newsTypeTermsQuery = newsTypeTerms.toLowerCase().replace(',', '+OR+').replace(' ', '+');
        var newsURL = 'https://news.google.com/news?cf=all&hl=en&pz=1&ned=us&q=' 
                        + newsTypeTermsQuery
                        + '&output=rss';     
        // build the return object                
        return {error: false, errorMessage: null,
                type: 'QUERY', terms: newsTypeTerms, url: newsURL};
    }
    // otherwise return generic error state
    return parseGoogleNewsRSSParamsErrorHelper('Unknown parameter error occured.');
    
    
}
function parseGoogleNewsRSSParams(params) {
    // get params of interest
    var newsType = params.newsType;
    var newsTypeTerms = params.newsTypeTerms;
    // if missing just one parameter flag error as such
    if ((newsType == undefined) && (newsTypeTerms != undefined))
        return parseGoogleNewsRSSParamsErrorHelper('Parameter newsTypeTerms set with no newsType set.');
    if ((newsType != undefined) && (newsTypeTerms == undefined))
        return parseGoogleNewsRSSParamsErrorHelper('Parameter newsType set with no newsTypeTerms set.');
    // if missing both parameters, set to default
    if ((newsType == undefined) && (newsTypeTerms == undefined)) {
        newsType = 'TOPIC';
        newsTypeTerms = 'HEADLINES';
    }
    // fix case parameters
    newsType = newsType.toUpperCase();
    newsTypeTerms = newsTypeTerms.toUpperCase();
    // expand newsType name if needed
    if (newsType == 'T')
        newsType = 'TOPIC';
    if (newsType == 'Q')
        newsType = 'QUERY';
    // if an invalid newsType set flag error as such
    if ((newsType != 'TOPIC') && (newsType != 'QUERY'))
        return parseGoogleNewsRSSParamsErrorHelper('Invalid newsType parameter specified.');
    // if type is topic
    if (newsType == 'TOPIC') {
        // init the short and long term names of the topic type
        var newsTypeTermTopicShort = null;
        var newsTypeTermTopicLong = null;
        // check the term for either short or long name and then set names accordingly
        if ((newsTypeTerms == 'H') || (newsTypeTerms == 'HEADLINES')) {
            newsTypeTermTopicShort = 'H';
            newsTypeTermTopicLong = 'HEADLINES';
        }
        if ((newsTypeTerms == 'N') || (newsTypeTerms == 'NATIONAL')) {
            newsTypeTermTopicShort = 'N';
            newsTypeTermTopicLong = 'NATIONAL';
        }
        if ((newsTypeTerms == 'W') || (newsTypeTerms == 'WORLD')) {
            newsTypeTermTopicShort = 'W';
            newsTypeTermTopicLong = 'WORLD';
        }        
        if ((newsTypeTerms == 'E') || (newsTypeTerms == 'ENTERTAINMENT')) {
            newsTypeTermTopicShort = 'E';
            newsTypeTermTopicLong = 'ENTERTAINMENT';
        }
        if ((newsTypeTerms == 'B') || (newsTypeTerms == 'BUSINESS')) {
            newsTypeTermTopicShort = 'B';
            newsTypeTermTopicLong = 'BUSINESS';
        }         
        if ((newsTypeTerms == 'S') || (newsTypeTerms == 'SPORTS')) {
            newsTypeTermTopicShort = 'S';
            newsTypeTermTopicLong = 'SPORTS';
        }
        if ((newsTypeTerms == 'T') || (newsTypeTerms == 'SCI/TECH')) {
            newsTypeTermTopicShort = 'T';
            newsTypeTermTopicLong = 'SCI/TECH';
        }
        if ((newsTypeTerms == 'TC') || (newsTypeTerms == 'TECHNOLOGY')) {
            newsTypeTermTopicShort = 'TC';
            newsTypeTermTopicLong = 'TECHNOLOGY';
        }
        // if nothing was set it was a bad topic type flag error as such
        if (newsTypeTermTopicShort == null)
            return parseGoogleNewsRSSParamsErrorHelper('Parameter newsTypeTerms is unknown for newsType TOPIC.');
        // build the request URL
        var newsURL = 'https://news.google.com/news?cf=all&hl=en&pz=1&ned=us&topic=' 
                        + newsTypeTermTopicShort.toLowerCase()
                        + '&output=rss';
        // build the return object                
        return {error: false, errorMessage: null,
                type: 'TOPIC', terms: newsTypeTermTopicLong, url: newsURL};
    }
    // if type is query
    if (newsType == 'QUERY') {
        var newsTypeTermsQuery = newsTypeTerms.toLowerCase().replace(',', '+OR+').replace(' ', '+');
        var newsURL = 'https://news.google.com/news?cf=all&hl=en&pz=1&ned=us&q=' 
                        + newsTypeTermsQuery
                        + '&output=rss';     
        // build the return object                
        return {error: false, errorMessage: null,
                type: 'QUERY', terms: newsTypeTerms, url: newsURL};
    }
    // otherwise return generic error state
    return parseGoogleNewsRSSParamsErrorHelper('Unknown parameter error occured.');
    
    
}
function parseGoogleNewsRSSParams ( params ) { // get params of interest
 var newsType = params . newsType ; var newsTypeTerms = params . newsTypeTerms ; // if missing just one parameter flag error as such
 if ( ( newsType == undefined ) && ( newsTypeTerms != undefined ) ) return parseGoogleNewsRSSParamsErrorHelper ( 'Parameter newsTypeTerms set with no newsType set.' ) ; if ( ( newsType != undefined ) && ( newsTypeTerms == undefined ) ) return parseGoogleNewsRSSParamsErrorHelper ( 'Parameter newsType set with no newsTypeTerms set.' ) ; // if missing both parameters, set to default
 if ( ( newsType == undefined ) && ( newsTypeTerms == undefined ) ) { newsType = 'TOPIC' ; newsTypeTerms = 'HEADLINES' ; } // fix case parameters
 newsType = newsType . toUpperCase ( ) ; newsTypeTerms = newsTypeTerms . toUpperCase ( ) ; // expand newsType name if needed
 if ( newsType == 'T' ) newsType = 'TOPIC' ; if ( newsType == 'Q' ) newsType = 'QUERY' ; // if an invalid newsType set flag error as such
 if ( ( newsType != 'TOPIC' ) && ( newsType != 'QUERY' ) ) return parseGoogleNewsRSSParamsErrorHelper ( 'Invalid newsType parameter specified.' ) ; // if type is topic
 if ( newsType == 'TOPIC' ) { // init the short and long term names of the topic type
 var newsTypeTermTopicShort = null ; var newsTypeTermTopicLong = null ; // check the term for either short or long name and then set names accordingly
 if ( ( newsTypeTerms == 'H' ) || ( newsTypeTerms == 'HEADLINES' ) ) { newsTypeTermTopicShort = 'H' ; newsTypeTermTopicLong = 'HEADLINES' ; } if ( ( newsTypeTerms == 'N' ) || ( newsTypeTerms == 'NATIONAL' ) ) { newsTypeTermTopicShort = 'N' ; newsTypeTermTopicLong = 'NATIONAL' ; } if ( ( newsTypeTerms == 'W' ) || ( newsTypeTerms == 'WORLD' ) ) { newsTypeTermTopicShort = 'W' ; newsTypeTermTopicLong = 'WORLD' ; } if ( ( newsTypeTerms == 'E' ) || ( newsTypeTerms == 'ENTERTAINMENT' ) ) { newsTypeTermTopicShort = 'E' ; newsTypeTermTopicLong = 'ENTERTAINMENT' ; } if ( ( newsTypeTerms == 'B' ) || ( newsTypeTerms == 'BUSINESS' ) ) { newsTypeTermTopicShort = 'B' ; newsTypeTermTopicLong = 'BUSINESS' ; } if ( ( newsTypeTerms == 'S' ) || ( newsTypeTerms == 'SPORTS' ) ) { newsTypeTermTopicShort = 'S' ; newsTypeTermTopicLong = 'SPORTS' ; } if ( ( newsTypeTerms == 'T' ) || ( newsTypeTerms == 'SCI/TECH' ) ) { newsTypeTermTopicShort = 'T' ; newsTypeTermTopicLong = 'SCI/TECH' ; } if ( ( newsTypeTerms == 'TC' ) || ( newsTypeTerms == 'TECHNOLOGY' ) ) { newsTypeTermTopicShort = 'TC' ; newsTypeTermTopicLong = 'TECHNOLOGY' ; } // if nothing was set it was a bad topic type flag error as such
 if ( newsTypeTermTopicShort == null ) return parseGoogleNewsRSSParamsErrorHelper ( 'Parameter newsTypeTerms is unknown for newsType TOPIC.' ) ; // build the request URL
 var newsURL = 'https://news.google.com/news?cf=all&hl=en&pz=1&ned=us&topic=' + newsTypeTermTopicShort . toLowerCase ( ) + '&output=rss' ; // build the return object                
 return { error : false , errorMessage : null , type : 'TOPIC' , terms : newsTypeTermTopicLong , url : newsURL } ; } // if type is query
 if ( newsType == 'QUERY' ) { var newsTypeTermsQuery = newsTypeTerms . toLowerCase ( ) . replace ( ',' , '+OR+' ) . replace ( ' ' , '+' ) ; var newsURL = 'https://news.google.com/news?cf=all&hl=en&pz=1&ned=us&q=' + newsTypeTermsQuery + '&output=rss' ; // build the return object                
 return { error : false , errorMessage : null , type : 'QUERY' , terms : newsTypeTerms , url : newsURL } ; } // otherwise return generic error state
 return parseGoogleNewsRSSParamsErrorHelper ( 'Unknown parameter error occured.' ) ; }
parse the initial paremeters specfied by the original calling params returns well defined types for type, terms, and the calling RSS URL
parse the initial paremeters specfied by the original calling params returns well defined types for type terms and the calling RSS URL