INNER CODE UNIT · JavaScript

urlIndex

pegaltier/awesome-utils-dev · node_scripts/wip-dedupe.js:65

const urlIndex = new Map(); // normalized url -> relative file path
const textIndex = []; // { file, content } for plain-text lookups

for (const file of files) {
    const content = fs.readFileSync(file, 'utf8');
    const rel = path.relative(ROOT, file);
    textIndex.push({ file: rel, content: content.toLowerCase() });
    for (const match of content.match(URL_RE) || []) {
        const norm = normalizeUrl(match);
        if (norm && !urlIndex.has(norm)) urlIndex.set(norm, rel);
    }
}

/** Where a WIP line already lives in the repo, or null. */
function findExisting(line) {
    const urls = line.match(URL_RE) || [];
    if (urls.length) {
        for (const url of urls) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…