MCPcopy Create free account
hub / github.com/PawanOsman/OpenCursor / globToRe

Function globToRe

src/agent/tools/shared.ts:139–147  ·  view source on GitHub ↗
(p: string)

Source from the content-addressed store, hash-verified

137
138/** Convert a glob (supporting **, *, ?) into an anchored RegExp. */
139export function globToRe(p: string): RegExp {
140 const esc = p
141 .replace(/[.+^${}()|[\]\\]/g, "\\$&")
142 .replace(/\*\*/g, "\u0000")
143 .replace(/\*/g, "[^/]*")
144 .replace(/\u0000/g, ".*")
145 .replace(/\?/g, ".");
146 return new RegExp(`^${esc}$`);
147}
148
149/** Substring/subsequence fuzzy score (higher = better; 0 = no match). */
150export function fuzzyScore(text: string, query: string): number {

Callers 2

files.tsFile · 0.90
search.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected