<commit_before>var respondWith = require("../util/responseUtil.js")
var url = require("url");

var pathRegex = /\/collect(\/(.*))*$/;

function handle(request, response) {
    console.log("Collecting beacon");
    var identifier = identifierFrom(request);
    if (identifier) {
        respondWith.okMessage(response, identifier);
    } else {
        respondWith.textPlain(response, 400, "Client should supply a beacon identifier");
    }
}

function identifierFrom(request) {
    var match = pathRegex.exec(path(request));
    var identifier = null;
    if (match) {
        identifier = match[2];
    }
    return identifier;
}

function shouldHandle(request) {
    return pathRegex.test(path(request));
}

function getHandlerName() {
    return "Beacon collector";
}

function path(request) {
    return url.parse(request.url).pathname;
}

exports.handle = handle;
exports.shouldHandle = shouldHandle;
exports.getHandlerName = getHandlerName;<commit_msg>Not using regex to match path<commit_after>var respondWith = require("../util/responseUtil.js")
var url = require("url");


function handle(request, response) {
    console.log("Collecting beacon");
    var identifier = identifierFrom(request);
    if (identifier) {
        respondWith.okMessage(response, identifier);
    } else {
        respondWith.textPlain(response, 400, "Client should supply a beacon identifier");
    }
}

function identifierFrom(request) {
    return path(request)[2];
}

function shouldHandle(request) {
    var firstSegment = path(request)[1];
    return "collect" === firstSegment;
}

function getHandlerName() {
    return "Beacon collector";
}

function path(request) {
    return url.parse(request.url).pathname.split("/");
}

exports.handle = handle;
exports.shouldHandle = shouldHandle;
exports.getHandlerName = getHandlerName;
{'fraction_non_alphanumeric': 0.13021978021978023, 'fraction_numerical': 0.004945054945054945, 'mean_word_length': 4.1440677966101696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2763698', 'n_tokens_mistral': 530, 'n_tokens_neox': 513, 'n_words': 121}