<commit_before>// Check every sources(img, stylesheets, scripts) are in same folder as spec document, and they are reachable.
import puppeteer from 'puppeteer';

const self = {
    name: 'links.linkchecker',
    section: 'document-body',
    rule: 'brokenLink',
};

const compound = {
    name: 'links.linkchecker',
    section: 'compound',
    rule: 'compoundFilesLocation',
};

const allowList = [
    /^https:\/\/www.w3.org\/StyleSheets/,
    /^https:\/\/www.w3.org\/scripts/,
    'https://www.w3.org/TR/tr-outdated-spec',
    /^https:\/\/www.w3.org\/analytics\/piwik/,
    /^https:\/\/test.csswg.org\/harness/,
    /^data:/,
];
const noRespondAllowList = [
    'https://www.w3.org/TR/tr-outdated-spec',
    'https://www.w3.org/analytics/piwik/matomo.js',
];

export const { name } = self;

/**
 * @param url
 */
function simplifyURL(url) {
    const urlObj = new URL(url);
    return (
        (urlObj.origin !== 'null' ? urlObj.origin : urlObj.protocol) +
        urlObj.pathname
    );
}

/**
 * Upgrade version of Array.include(). The array can be RegExp
 *<commit_msg>allow links to cdn.w3.org/assets (#1564)<commit_after>// Check every sources(img, stylesheets, scripts) are in same folder as spec document, and they are reachable.
import puppeteer from 'puppeteer';

const self = {
    name: 'links.linkchecker',
    section: 'document-body',
    rule: 'brokenLink',
};

const compound = {
    name: 'links.linkchecker',
    section: 'compound',
    rule: 'compoundFilesLocation',
};

const allowList = [
    /^https:\/\/www.w3.org\/StyleSheets/,
    /^https:\/\/www.w3.org\/scripts/,
    'https://www.w3.org/TR/tr-outdated-spec',
    /^https:\/\/www.w3.org\/analytics\/piwik/,
    /^https:\/\/test.csswg.org\/harness/,
    /^https:\/\/cdn.w3.org\/assets\//,
    /^data:/,
];
const noRespondAllowList = [
    'https://www.w3.org/TR/tr-outdated-spec',
    'https://www.w3.org/analytics/piwik/matomo.js',
];

export const { name } = self;

/**
 * @param url
 */
function simplifyURL(url) {
    const urlObj = new URL(url);
    return (
        (urlObj.origin !== 'null' ? urlObj.origin : urlObj.protocol) +
        urlObj.pathname
    );
}

/**
 * Upgrade version of Array.include(). The array can be RegExp
 *
{'fraction_non_alphanumeric': 0.18710550045085664, 'fraction_numerical': 0.008115419296663661, 'mean_word_length': 2.767402376910017, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 12, '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': '4487648', 'n_tokens_mistral': 817, 'n_tokens_neox': 801, 'n_words': 157}