MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / extractMatchPatternsFromGlobs

Function extractMatchPatternsFromGlobs

src/pkg/utils/url_matcher.ts:398–410  ·  view source on GitHub ↗
(globs: string[])

Source from the content-addressed store, hash-verified

396};
397
398export const extractMatchPatternsFromGlobs = (globs: string[]): (string | null)[] => {
399 return globs.map((glob) => {
400 if (glob.startsWith("http*://")) {
401 glob = `*://${glob.substring(8)}`;
402 }
403 const extMatch = checkUrlMatch(glob);
404 if (!extMatch) return null;
405 const [scheme, host] = extMatch;
406 // glob 的 *.google.com 可以匹配 www.google.com 跟 my-website.com/abc.google.com
407 if (host.charAt(0) === ".") return null;
408 return `${scheme}://${host}/*`;
409 });
410};
411
412export const extractSchemesOfGlobs = (globs: string[]): string[] => {
413 const set = new Set(["*://*/*"]);

Callers 2

getApiMatchesAndGlobsFunction · 0.85

Calls 1

checkUrlMatchFunction · 0.85

Tested by

no test coverage detected