<commit_before>// Node.js / browser support
var isNodeJS = false;
if (typeof exports === 'undefined') {
    exports = {};
}

if (typeof module !== 'undefined') {
    isNodeJS = true;
}

var path;

if (isNodeJS) {
    pathHelper = require('path');
}

// Common namespace for browsers
var common = {};




// --- CHALLENGE ACTIVE SETTING ---
// Set to true to enable challenge active mode
// so that the routes are requestable.
// This is a function so we can return a boolean
// based on the current date being within a set date range, for example.
var challengeActive = exports.challengeActive = common.challengeActive = function() {
    return true;
}


var formAbsoluteURI = exports.formAbsoluteURI = common.formAbsoluteURI = function(path, options) {
    if (isNodeJS) {
        var url = require('url');
        
        if (!options) {
            options = require('../../enums.json').options;
        }
        
        if (path) {
            options.pathname = path;
        }
        
        return url.format(options);
    }
}

var tagize = exports.tagize = common.tagize = function(string) {
    return splitIntoTags(string).map(normalizeTag);
};



var campaign = exports.campaign = common.campaign = function() {
    var campaigns = {
        trial: 'VerilyTrial',
        main: 'VerilyLive'
    }
    return campaigns.main;
}

var campaigner = exports.campaigner = common.campaigner = function(medium, text, link) {    
    if (medium === 'twitter') {
        return {
            hashtags: campaign()
        };
    } else if (medium === 'email') {
        return {
            subject: text + ' #' + campaign(),
            body: text + ' – ' +  link + ' %0D%0A%0D%0AAnswer this with Verily, a crowdsourced verification platform.'
        };
    }
};


var splitIntoTags = exports.splitIntoTags = common.splitIntoTags = function(string) {
    return string.split(',').filter(function(tag) {
        // Do not include just whitespace elements.
        if (tag && !(/^\s+$/.test(tag))) {
            return tag;
        }

    });
};

// Make tags friendly for URIs.
// Replace multiple instances of whitespace with '-'.
// e.g. turn " " into "-".
var normalizeTag = exports.normalizeTag = common.normalizeTag = exports.normalizeString = common.normalizeString = function(tag) {
    // Just remove apostrophes, don't replace them with '-'.
    // If after the first replace there is just 1 '-' at start or end, remove it, or if there are 2 or more hyphens (-), trim to 1 '-'.
    return tag.trim().toLowerCase().replace(/'/g, '').replace(/[\s/\\#._!@$£€%^?<>{}\[\]&*+=:;"`~]+/g, '-').replace(/-{2,}/g, '-' ).replace(/(^-)?(-$)?/g, '');    
};

// Pretty paths for canonical URLs
var prettyPath = exports.prettyPath = common.prettyPath = function(data) {
    var path = data.path;
    var prefix = data.prefix;
    var postPrefix = data.postPrefix;
    if (isNodeJS && pathHelper && data.hasOwnProperty('req')) {
        if (data.sameLevel || !postPrefix) {
            path = pathHelper.dirname(data.req.path);
        } else {
            path = data.req.path;
        }
        
        if (prefix) {
            path = pathHelper.join(prefix, path);
        }
        
        if (postPrefix) {
            path = pathHelper.join(path, postPrefix);
        }
    }
    
    return path + '/' + common.normalizeString(data.id + '-' + data.string);
};




var getYears = exports.getYears = common.getYears = function() {<commit_msg>shouldn't be using pathHelper.join for URLs<commit_after>// Node.js / browser support
var isNodeJS = false;
if (typeof exports === 'undefined') {
    exports = {};
}

if (typeof module !== 'undefined') {
    isNodeJS = true;
}

var path;

if (isNodeJS) {
    pathHelper = require('path');
}

// Common namespace for browsers
var common = {};




// --- CHALLENGE ACTIVE SETTING ---
// Set to true to enable challenge active mode
// so that the routes are requestable.
// This is a function so we can return a boolean
// based on the current date being within a set date range, for example.
var challengeActive = exports.challengeActive = common.challengeActive = function() {
    return true;
}


var formAbsoluteURI = exports.formAbsoluteURI = common.formAbsoluteURI = function(path, options) {
    if (isNodeJS) {
        var url = require('url');
        
        if (!options) {
            options = require('../../enums.json').options;
        }
        
        if (path) {
            options.pathname = path;
        }
        
        return url.format(options);
    }
}

var tagize = exports.tagize = common.tagize = function(string) {
    return splitIntoTags(string).map(normalizeTag);
};



var campaign = exports.campaign = common.campaign = function() {
    var campaigns = {
        trial: 'VerilyTrial',
        main: 'VerilyLive'
    }
    return campaigns.main;
}

var campaigner = exports.campaigner = common.campaigner = function(medium, text, link) {    
    if (medium === 'twitter') {
        return {
            hashtags: campaign()
        };
    } else if (medium === 'email') {
        return {
            subject: text + ' #' + campaign(),
            body: text + ' – ' +  link + ' %0D%0A%0D%0AAnswer this with Verily, a crowdsourced verification platform.'
        };
    }
};


var splitIntoTags = exports.splitIntoTags = common.splitIntoTags = function(string) {
    return string.split(',').filter(function(tag) {
        // Do not include just whitespace elements.
        if (tag && !(/^\s+$/.test(tag))) {
            return tag;
        }

    });
};

// Make tags friendly for URIs.
// Replace multiple instances of whitespace with '-'.
// e.g. turn " " into "-".
var normalizeTag = exports.normalizeTag = common.normalizeTag = exports.normalizeString = common.normalizeString = function(tag) {
    // Just remove apostrophes, don't replace them with '-'.
    // If after the first replace there is just 1 '-' at start or end, remove it, or if there are 2 or more hyphens (-), trim to 1 '-'.
    return tag.trim().toLowerCase().replace(/'/g, '').replace(/[\s/\\#._!@$£€%^?<>{}\[\]&*+=:;"`~]+/g, '-').replace(/-{2,}/g, '-' ).replace(/(^-)?(-$)?/g, '');    
};

// Pretty paths for canonical URLs
var prettyPath = exports.prettyPath = common.prettyPath = function(data) {
    var path = data.path;
    var prefix = data.prefix;
    var postPrefix = data.postPrefix;
    if (isNodeJS && pathHelper && data.hasOwnProperty('req')) {
        if (data.sameLevel || !postPrefix) {
            path = pathHelper.dirname(data.req.path);
        } else {
            path = data.req.path;
        }
        
        if (prefix) {
            path = prefix + '/' + path;
        }
        
        if (postPrefix) {
            path += '/' + postPrefix;
        }
    }
    
    return path + '/' + common.normalizeString(data.id + '-' + data.string);
};




var getYears = exports.getYears = common.getYears = function() {
{'fraction_non_alphanumeric': 0.15126050420168066, 'fraction_numerical': 0.0023181686467690526, 'mean_word_length': 2.313970235237638, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1833513', 'n_tokens_mistral': 2109, 'n_tokens_neox': 2040, 'n_words': 560}