refactor: remove dead code and improve string concatenation · openclaw/openclaw@a34ddce
Pommelle
·
2026-06-16
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -39,9 +39,6 @@ export function extractBalancedJsonPrefix(
|
39 | 39 | let escaped = false; |
40 | 40 | for (let i = start; i < raw.length; i += 1) { |
41 | 41 | const char = raw[i]; |
42 | | -if (char === undefined) { |
43 | | -break; |
44 | | -} |
45 | 42 | if (inString) { |
46 | 43 | // Delimiters inside strings are data, not structure. Track escapes so an |
47 | 44 | // escaped quote does not prematurely end string mode. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -95,15 +95,15 @@ export function stripInlineDirectiveTagsForDisplay(text: string): StripInlineDir
|
95 | 95 | } |
96 | 96 | |
97 | 97 | function stripUnsafeReplyDirectiveChars(value: string): string { |
98 | | -let next = ""; |
| 98 | +const chars: string[] = []; |
99 | 99 | for (const ch of value) { |
100 | 100 | const code = ch.charCodeAt(0); |
101 | 101 | if ((code >= 0 && code <= 31) || code === 127 || ch === "[" || ch === "]") { |
102 | 102 | continue; |
103 | 103 | } |
104 | | -next += ch; |
| 104 | +chars.push(ch); |
105 | 105 | } |
106 | | -return next; |
| 106 | +return chars.join(""); |
107 | 107 | } |
108 | 108 | |
109 | 109 | export function sanitizeReplyDirectiveId(rawReplyToId?: string): string | undefined { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -22,14 +22,14 @@ export function normalizeSecretInput(value: unknown): string {
|
22 | 22 | return ""; |
23 | 23 | } |
24 | 24 | const collapsed = value.replace(/[\r\n\u2028\u2029]+/g, ""); |
25 | | -let latin1Only = ""; |
| 25 | +const chars: string[] = []; |
26 | 26 | for (const char of collapsed) { |
27 | 27 | const codePoint = char.codePointAt(0); |
28 | 28 | if (typeof codePoint === "number" && codePoint <= 0xff) { |
29 | | -latin1Only += char; |
| 29 | +chars.push(char); |
30 | 30 | } |
31 | 31 | } |
32 | | -return latin1Only.trim(); |
| 32 | +return chars.join("").trim(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -38,5 +38,5 @@ export function normalizeSecretInput(value: unknown): string {
|
38 | 38 | */ |
39 | 39 | export function normalizeOptionalSecretInput(value: unknown): string | undefined { |
40 | 40 | const normalized = normalizeSecretInput(value); |
41 | | -return normalized ? normalized : undefined; |
| 41 | +return normalized || undefined; |
42 | 42 | } |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -105,9 +105,6 @@ export function formatUsd(value?: number): string | undefined {
|
105 | 105 | if (value === undefined || !Number.isFinite(value)) { |
106 | 106 | return undefined; |
107 | 107 | } |
108 | | -if (value >= 1) { |
109 | | -return `$${value.toFixed(2)}`; |
110 | | -} |
111 | 108 | if (value >= 0.01) { |
112 | 109 | return `$${value.toFixed(2)}`; |
113 | 110 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。