<commit_before>const paramPattern = /:(\w+)(?:!(\w+))?/g;

const typePattern = type => {
    switch (type) {
        case 'any':
            return '.+';
        case 'number':
            return '\\d+';
        default:
            return '[^/]+';
    }
};
const convert = type => {
    switch (type) {
        case 'number':
            return value => Number(value);
        default:
            return value => value;
    }
};

function route(pattern) {
    const parameterNames = [];
    const conversions = [];

    const rxPattern = pattern.replace(paramPattern, (match, parameterName, type) => {
        parameterNames.push(parameterName);
        conversions.push(convert(type));
        return `(${typePattern(type)})`;
    });

    const rx = new RegExp(`^${rxPattern}$`);

    return function(url) {
        const match = url.match(rx);
        if (!match) {
            return;
        }
        const [, ...captures] = match;<commit_msg>support negative numbers<commit_after>const paramPattern = /:(\w+)(?:!(\w+))?/g;

const typePattern = type => {
    switch (type) {
        case 'any':
            return '.+';
        case 'number':
            return '-?\\d+';
        default:
            return '[^/]+';
    }
};
const convert = type => {
    switch (type) {
        case 'number':
            return value => Number(value);
        default:
            return value => value;
    }
};

function route(pattern) {
    const parameterNames = [];
    const conversions = [];

    const rxPattern = pattern.replace(paramPattern, (match, parameterName, type) => {
        parameterNames.push(parameterName);
        conversions.push(convert(type));
        return `(${typePattern(type)})`;
    });

    const rx = new RegExp(`^${rxPattern}$`);

    return function(url) {
        const match = url.match(rx);
        if (!match) {
            return;
        }
        const [, ...captures] = match;
{'fraction_non_alphanumeric': 0.16605744125326372, 'fraction_numerical': 0.0, 'mean_word_length': 1.9567901234567902, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4517125', 'n_tokens_mistral': 562, 'n_tokens_neox': 548, 'n_words': 125}