UNPKG

scai

Version:

> AI-powered CLI tool for commit messages **and** pull request reviews — using local models.

20 lines (19 loc) 696 B
// src/utils/normalizePath.ts import path from "path"; /** * Normalizes a path string for loose, fuzzy matching: * - Lowercases * - Removes slashes and backslashes * - Removes whitespace */ export function normalizePathForLooseMatch(p) { return p.toLowerCase().replace(/[\\/]/g, '').replace(/\s+/g, ''); } // Helper to normalize and resolve paths to a consistent format (forward slashes) export function normalizePath(p) { return path.resolve(p).replace(/\\/g, '/'); } export function getRepoKeyForPath(pathToMatch, config) { const norm = normalizePath(pathToMatch); return Object.entries(config.repos).find(([, val]) => normalizePath(val.indexDir) === norm)?.[0] || null; }