UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

42 lines (41 loc) • 1.13 kB
//#region src/infra/git-path-quote.ts const escapes = /* @__PURE__ */ new Map([ [97, 7], [98, 8], [102, 12], [110, 10], [114, 13], [116, 9], [118, 11], [34, 34], [92, 92] ]); /** Git quote.c unquote_c_style: octal escapes encode bytes, not Unicode code points. */ function unquoteGitPath(input, start = 0) { if (input[start] !== 34) return; const output = []; for (let index = start + 1; index < input.length; index++) { let byte = input[index]; if (byte === 0) return; if (byte === 34) return { bytes: Buffer.from(output), end: index + 1 }; if (byte === 92) { const escaped = input[++index]; if (escaped === void 0) return; const decoded = escapes.get(escaped); if (decoded !== void 0) byte = decoded; else { const second = input[index + 1]; const third = input[index + 2]; if (escaped < 48 || escaped > 51 || second === void 0 || second < 48 || second > 55 || third === void 0 || third < 48 || third > 55) return; byte = escaped - 48 << 6 | second - 48 << 3 | third - 48; index += 2; } } output.push(byte); } } //#endregion export { unquoteGitPath as t };