<commit_before>VotesCollection = new Mongo.Collection('votesCollection');

Meteor.methods({
    voteInsert: function(voteAttributes) {
        check(Meteor.userId(), String);
        check(voteAttributes, {
            title: String,
            jurisType: String,
            jurisName: String,
            officialLink: String,
            problem: String,
            voteBody: String,
            isofficial: Boolean


        });
        if (_.include(voteAttributes.officialLink.toString(), ".gov.au")) { //Check underscore documentation, does not find .gov.au when exists in string
            console.log("found .gov.au");
        } else {
            // throw new Meteor.Error('invalid', 'The official link provided is incorrect.')
        }

        var user = Meteor.user();
        var vote = _.extend(voteAttributes, {
            userID: user._id,
            author: user.username,
            submitted: new Date(),
            yesVotes: 0,
            noVotes: 0,
            abstains: 0,
            yesVoters: [],
            noVoters: [],
            abstainers: [],
            totalVotes: 0
        });
        var voteId = VotesCollection.insert(vote);
        return {
            _id: voteId
        }; },

    voteYes: function (voteId) {
        check(Meteor.userId(), String);
        check(voteId, String);
<commit_msg>Fix issue #7 - validate url contains .gov.au<commit_after>VotesCollection = new Mongo.Collection('votesCollection');

Meteor.methods({
    voteInsert: function(voteAttributes) {
        check(Meteor.userId(), String);
        check(voteAttributes, {
            title: String,
            jurisType: String,
            jurisName: String,
            officialLink: String,
            problem: String,
            voteBody: String,
            isofficial: Boolean


        });
        if (voteAttributes.officialLink.indexOf('.gov.au') >= 0) {
            console.log("found .gov.au");
        } else {
            throw new Meteor.Error('invalid', 'The official link provided is incorrect.')
        }

        var user = Meteor.user();
        var vote = _.extend(voteAttributes, {
            userID: user._id,
            author: user.username,
            submitted: new Date(),
            yesVotes: 0,
            noVotes: 0,
            abstains: 0,
            yesVoters: [],
            noVoters: [],
            abstainers: [],
            totalVotes: 0
        });
        var voteId = VotesCollection.insert(vote);
        return {
            _id: voteId
        }; },

    voteYes: function (voteId) {
        check(Meteor.userId(), String);
        check(voteId, String);

{'fraction_non_alphanumeric': 0.11414486158513462, 'fraction_numerical': 0.0037921880925293893, 'mean_word_length': 1.6727456940222898, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3481283', 'n_tokens_mistral': 724, 'n_tokens_neox': 704, 'n_words': 167}