MCPcopy Create free account
hub / github.com/angular/dev-infra / argStringToArray

Function argStringToArray

github-actions/browserstack/set-browserstack-env.js:20387–20430  ·  view source on GitHub ↗
(argString)

Source from the content-addressed store, hash-verified

20385 if (!arg) {
20386 return '""';
20387 }
20388 const cmdSpecialChars = [
20389 " ",
20390 " ",
20391 "&",
20392 "(",
20393 ")",
20394 "[",
20395 "]",
20396 "{",
20397 "}",
20398 "^",
20399 "=",
20400 ";",
20401 "!",
20402 "'",
20403 "+",
20404 ",",
20405 "`",
20406 "~",
20407 "|",
20408 "<",
20409 ">",
20410 '"'
20411 ];
20412 let needsQuotes = false;
20413 for (const char of arg) {
20414 if (cmdSpecialChars.some((x) => x === char)) {
20415 needsQuotes = true;
20416 break;
20417 }
20418 }
20419 if (!needsQuotes) {
20420 return arg;
20421 }
20422 let reverse = '"';
20423 let quoteHit = true;
20424 for (let i = arg.length; i > 0; i--) {
20425 reverse += arg[i - 1];
20426 if (quoteHit && arg[i - 1] === "\\") {
20427 reverse += "\\";
20428 } else if (arg[i - 1] === '"') {
20429 quoteHit = true;
20430 reverse += '"';
20431 } else {
20432 quoteHit = false;
20433 }

Callers 1

execFunction · 0.70

Calls 2

appendFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected