test: simplify safe-bin doc normalization · openclaw/openclaw@3dfc4d8
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,14 +26,21 @@ function normalizeGeneratedDocBlock(block: string): string {
|
26 | 26 | while (lines.at(-1)?.trim() === "") { |
27 | 27 | lines.pop(); |
28 | 28 | } |
29 | | -const indents = lines |
30 | | -.filter((line) => line.trim().length > 0) |
31 | | -.map((line) => line.match(/^ */)?.[0].length ?? 0); |
32 | | -const commonIndent = Math.min(...indents); |
| 29 | +let commonIndent = Infinity; |
| 30 | +for (const line of lines) { |
| 31 | +if (line.trim().length === 0) { |
| 32 | +continue; |
| 33 | +} |
| 34 | +commonIndent = Math.min(commonIndent, line.match(/^ */)?.[0].length ?? 0); |
| 35 | +} |
33 | 36 | if (commonIndent <= 0) { |
34 | 37 | return lines.join("\n"); |
35 | 38 | } |
36 | | -return lines.map((line) => line.slice(Math.min(line.length, commonIndent))).join("\n"); |
| 39 | +const normalizedLines: string[] = []; |
| 40 | +for (const line of lines) { |
| 41 | +normalizedLines.push(line.slice(Math.min(line.length, commonIndent))); |
| 42 | +} |
| 43 | +return normalizedLines.join("\n"); |
37 | 44 | } |
38 | 45 | |
39 | 46 | function buildDeniedFlagArgvVariants(flag: string): string[][] { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。