<commit_before>//polyfill String.contains
if (!String.prototype.contains) {
    String.prototype.contains = function () {
        return String.prototype.indexOf.apply(this, arguments) !== -1;
    };
}

module.exports.getPage = function(req){
    return Number(req.query['page']) || 1;
};
module.exports.getRestriction = function(page, page_size){
    if (!page) throw new Error('page undefined');
    if (page < 0) throw new Error('page must be a positive number');

    if (!page_size) throw new Error('page_size undefined');
    if (page_size < 0) throw new Error('page_size must be a positive number');

    return {
        skip: (page - 1) * page_size,
        limit: page_size
    }
};
module.exports.getLink = function(req, queryString, paging, more){
    function getHref(req) {
        return req.protocol + '://' + req.headers.host + req.originalUrl.split('?')[0];
    }

    var self = getHref(req) + queryString;

    var link = [];
    link.push({rel: 'self', href: self});

    if (paging.page > 1){
        var previous = self.replace('page=' + (paging.page), 'page=' + (paging.page - 1));
        link.push({rel: 'previous', href: previous});
    }

    if (more) {
        var next = self.replace('page=' + (paging.page), 'page=' + (paging.page + 1));
        link.push({rel: 'next', href: next});
    }

    return link;
};<commit_msg>Fix Bundle link URL to show correct source when running behind a server providing SSL termination<commit_after>//polyfill String.contains
if (!String.prototype.contains) {
    String.prototype.contains = function () {
        return String.prototype.indexOf.apply(this, arguments) !== -1;
    };
}

module.exports.getPage = function(req){
    return Number(req.query['page']) || 1;
};
module.exports.getRestriction = function(page, page_size){
    if (!page) throw new Error('page undefined');
    if (page < 0) throw new Error('page must be a positive number');

    if (!page_size) throw new Error('page_size undefined');
    if (page_size < 0) throw new Error('page_size must be a positive number');

    return {
        skip: (page - 1) * page_size,
        limit: page_size
    }
};
module.exports.getLink = function(req, queryString, paging, more){
    function getHref(req) {
        var protocol = req.headers['x-forwarded-proto'] || req.protocol;
        return protocol + '://' + req.headers.host + req.originalUrl.split('?')[0];
    }

    var self = getHref(req) + queryString;

    var link = [];
    link.push({rel: 'self', href: self});

    if (paging.page > 1){
        var previous = self.replace('page=' + (paging.page), 'page=' + (paging.page - 1));
        link.push({rel: 'previous', href: previous});
    }

    if (more) {
        var next = self.replace('page=' + (paging.page), 'page=' + (paging.page + 1));
        link.push({rel: 'next', href: next});
    }

    return link;
};
{'fraction_non_alphanumeric': 0.16532680880810904, 'fraction_numerical': 0.006291506466270535, 'mean_word_length': 3.071123755334282, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5543421', 'n_tokens_mistral': 919, 'n_tokens_neox': 886, 'n_words': 237}