INNER CODE UNIT · JavaScript

findExisting

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

function findExisting(line) {
    const urls = line.match(URL_RE) || [];
    if (urls.length) {
        for (const url of urls) {
            const norm = normalizeUrl(url);
            if (norm && urlIndex.has(norm)) return urlIndex.get(norm);
        }
        return null;
    }
    // plain text line: needs a literal (case-insensitive) hit somewhere
    const needle = line.trim().toLowerCase();
    if (needle.length < 4) return null;
    const hit = textIndex.find((f) => f.content.includes(needle));
    return hit ? hit.file : null;
}

// --- process WIP.md ---------------------------------------------------------

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…