MCPcopy Create free account
hub / github.com/pbakaus/impeccable / pythonStringArg

Function pythonStringArg

skill/scripts/hook-before-edit.mjs:284–310  ·  view source on GitHub ↗
(script, prefixRe)

Source from the content-addressed store, hash-verified

282}
283
284function pythonStringArg(script, prefixRe) {
285 let prefix;
286 while ((prefix = prefixRe.exec(script))) {
287 const start = prefixRe.lastIndex;
288 const triple = script.slice(start, start + 3);
289 if (triple === "'''" || triple === '"""') {
290 const end = script.indexOf(triple, start + 3);
291 if (end !== -1) return script.slice(start + 3, end);
292 continue;
293 }
294 const quote = script[start];
295 if (quote !== '"' && quote !== "'") continue;
296 let out = '';
297 for (let i = start + 1; i < script.length; i++) {
298 const ch = script[i];
299 if (ch === '\\') {
300 out += script[i + 1] || '';
301 i += 1;
302 } else if (ch === quote) {
303 return out;
304 } else {
305 out += ch;
306 }
307 }
308 }
309 return '';
310}
311
312function escapeRegExp(value) {
313 return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');

Callers 1

shellPythonWriteContentFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected