MCPcopy Index your code
hub / github.com/darkreader/darkreader / processSiteFixesConfigBlock

Function processSiteFixesConfigBlock

src/generators/utils/parse.ts:71–90  ·  view source on GitHub ↗
(text: string, offsets: Array<[number, number]>, recordStart: number, recordEnd: number, urls: Array<readonly string[]>)

Source from the content-addressed store, hash-verified

69}
70
71function processSiteFixesConfigBlock(text: string, offsets: Array<[number, number]>, recordStart: number, recordEnd: number, urls: Array<readonly string[]>) {
72 // TODO: more formal definition of URLs and delimiters
73 const block = text.substring(recordStart, recordEnd);
74 const lines = block.split('\n');
75 const commandIndices: number[] = [];
76 lines.forEach((ln, i) => {
77 if (ln.match(/^[A-Z]+(\s[A-Z]+){0,2}$/)) {
78 commandIndices.push(i);
79 }
80 });
81
82 if (commandIndices.length === 0) {
83 return;
84 }
85
86 offsets.push([recordStart, recordEnd - recordStart]);
87
88 const urls_ = parseArray(lines.slice(0, commandIndices[0]).join('\n'));
89 urls.push(urls_);
90}
91
92function extractURLsFromSiteFixesConfig(text: string): {urls: string[][]; offsets: Array<[number, number]>} {
93 const urls: string[][] = [];

Callers 1

Calls 1

parseArrayFunction · 0.90

Tested by

no test coverage detected