MCPcopy Index your code
hub / github.com/Dimillian/CodexMonitor / trimAtPipe

Function trimAtPipe

src/utils/threadItems.explore.ts:123–152  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

121}
122
123function trimAtPipe(command: string) {
124 if (!command) {
125 return "";
126 }
127 let inSingle = false;
128 let inDouble = false;
129 for (let index = 0; index < command.length; index += 1) {
130 const char = command[index];
131 if (char === "'" && !inDouble) {
132 inSingle = !inSingle;
133 continue;
134 }
135 if (char === '"' && !inSingle) {
136 inDouble = !inDouble;
137 continue;
138 }
139 if (char !== "|" || inSingle || inDouble) {
140 continue;
141 }
142 const prev = index > 0 ? command[index - 1] : "";
143 const next = index + 1 < command.length ? command[index + 1] : "";
144 const prevIsSpace = prev === "" || /\s/.test(prev);
145 const nextIsSpace = next === "" || /\s/.test(next);
146 if (!prevIsSpace || !nextIsSpace) {
147 continue;
148 }
149 return command.slice(0, index).trim();
150 }
151 return command.trim();
152}
153
154function isOptionToken(token: string) {
155 return token.startsWith("-");

Callers 1

splitCommandSegmentsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected