<commit_before>'use strict';

const removeExtension = require('./util/removeExtension');

// https://coveralls.io/github/${user}/${package}.svg?branch=${branch}
// https://img.shields.io/coveralls/${user}/${repo}.svg
// https://img.shields.io/coveralls/${user}/${repo}/${branch}.svg

function extractData(url) {
    let match;
    let data;

    if (url.indexOf('img.shields.io') !== -1) {
        match = url.match(/img.shields.io\/coveralls\/(.+)\/(.+).*/);

        if (!match) {
            return null;
        }

        data = { user: match[1], repo: removeExtension(match[2]) };

        // Support branches
        if (data.repo.split('/').length > 1) {
            data.branch = data.repo.split('/')[1];
            data.repo = data.repo.split('/')[0];
        }

        return data;
    }

    match = url.match(/coveralls.io\/github\/(.+)\/(.+).*/);

    if (!match) {
        return null;
    }

    return { user: match[1], repo: removeExtension(match[2]) };
}

module.exports = function (url) {
    const data = extractData(url.href.split('?')[0]);

    if (!data) {
        return null;
    }

    return {
        url: url.href,
        originalUrl: url.href,
        metaUrl: `https://img.shields.io/coveralls/${data.user}/${data.repo}${data.branch ? '/' + data.branch : ''}.json`,
        type: 'coveralls',<commit_msg>Coveralls native api support<commit_after>'use strict';

const removeExtension = require('./util/removeExtension');

// https://coveralls.io/repos/github/${user}/${package}/badge.svg?branch=${branch}
// https://coveralls.io/repos/${user}/${package}/badge.svg?branch=${branch}
// https://img.shields.io/coveralls/${user}/${repo}.svg
// https://img.shields.io/coveralls/${user}/${repo}/${branch}.svg

function extractData(url) {
    let match;
    let data;

    if (url.indexOf('img.shields.io') !== -1) {
        match = url.match(/img.shields.io\/coveralls\/(.+)\/(.+).*/);

        if (!match) {
            return null;
        }

        data = { user: match[1], repo: removeExtension(match[2]) };

        // Support branches
        if (data.repo.split('/').length > 1) {
            data.branch = data.repo.split('/')[1];
            data.repo = data.repo.split('/')[0];
        }

        return data;
    }

    match = url.match(/coveralls.io\/(.+)/);

    if (!match) {
        return null;
    }

    // repos/[github]/IndigoUnited/js-promtie/badge.svg -> ['js-promtie', 'IndigoUnited']
    match = match[1].split('/').reverse();
    match.shift();

    return { user: match[1], repo: match[0] };
}

module.exports = function (url) {
    const data = extractData(url.href.split('?')[0]);

    if (!data) {
        return null;
    }

    return {
        url: `https://coveralls.io/repos/${data.user}/${data.repo}/badge.svg`,
        originalUrl: url.href,
        metaUrl: `https://img.shields.io/coveralls/${data.user}/${data.repo}${data.branch ? '/' + data.branch : ''}.json`,
        type: 'coveralls',
{'fraction_non_alphanumeric': 0.21880284071694284, 'fraction_numerical': 0.006425431180250254, 'mean_word_length': 2.357548240635641, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 10, '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': '6463350', 'n_tokens_mistral': 1011, 'n_tokens_neox': 970, 'n_words': 151}