UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 602 B
//!src/daemon/arg-split.ts function splitArgsPreservingQuotes(e,t){const n=[];let r=null;let i=null;const a=t?.escapeMode??`none`;const o=new Set(t?.quoteChars??[`"`]);const s=t?.quoteStart??`anywhere`;for(let t=0;t<e.length;t++){const c=e.charAt(t);if(c===`\\`&&(a===`backslash`||a===`backslash-quote-only`&&e[t+1]===`"`)){if(t+1<e.length){r=(r??``)+e[t+1];t++}continue}if(o.has(c)){if(i===c){i=null;continue}if(!i&&(s===`anywhere`||!r)){i=c;r??=``;continue}}if(!i&&/\s/.test(c)){if(r!==null){n.push(r);r=null}continue}r=(r??``)+c}if(r!==null)n.push(r);return n}export{splitArgsPreservingQuotes as t};