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

Function extractSchemesOfGlobs

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

Source from the content-addressed store, hash-verified

410};
411
412export const extractSchemesOfGlobs = (globs: string[]): string[] => {
413 const set = new Set(["*://*/*"]);
414 for (const glob of globs) {
415 const m = /^([-\w]+):\/\//.exec(glob);
416 if (m && m[1]) {
417 if (!m[1].startsWith("http")) {
418 if (m[1] === "file") {
419 // https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns#invalid_match_patterns
420 set.add(`${m[1]}:///*`);
421 } else {
422 set.add(`${m[1]}://*/*`);
423 }
424 }
425 }
426 }
427 return [...set];
428};
429
430export const getApiMatchesAndGlobs = (scriptUrlPatterns: URLRuleEntry[]) => {
431 const urlMatching = scriptUrlPatterns.filter((e) => e.ruleType === RuleType.MATCH_INCLUDE);

Callers 2

getApiMatchesAndGlobsFunction · 0.85

Calls 1

addMethod · 0.80

Tested by

no test coverage detected