mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-29 18:12:52 +00:00
refactor: dedupe command config lowercase helpers
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { normalizeLowercaseStringOrEmpty } from "../string-coerce.js";
|
||||
import { findCodeRegions, isInsideCode } from "./code-regions.js";
|
||||
import { stripModelSpecialTokens } from "./model-special-tokens.js";
|
||||
import {
|
||||
@@ -133,7 +134,7 @@ function parseToolCallTagAt(text: string, start: number): ParsedToolCallTag | nu
|
||||
cursor += 1;
|
||||
}
|
||||
|
||||
const tagName = text.slice(nameStart, cursor).toLowerCase();
|
||||
const tagName = normalizeLowercaseStringOrEmpty(text.slice(nameStart, cursor));
|
||||
if (!TOOL_CALL_TAG_NAMES.has(tagName) || !isToolCallBoundary(text[cursor])) {
|
||||
return null;
|
||||
}
|
||||
@@ -391,7 +392,7 @@ export function stripDowngradedToolCallText(text: string): string {
|
||||
while (index < input.length && (input[index] === " " || input[index] === "\t")) {
|
||||
index += 1;
|
||||
}
|
||||
if (input.slice(index, index + 9).toLowerCase() === "arguments") {
|
||||
if (normalizeLowercaseStringOrEmpty(input.slice(index, index + 9)) === "arguments") {
|
||||
index += 9;
|
||||
if (input[index] === ":") {
|
||||
index += 1;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { normalizeLowercaseStringOrEmpty } from "../string-coerce.js";
|
||||
|
||||
const FILE_REF_EXTENSIONS = ["md", "go", "py", "pl", "sh", "am", "at", "be", "cc"] as const;
|
||||
|
||||
export const FILE_REF_EXTENSIONS_WITH_TLD = new Set<string>(FILE_REF_EXTENSIONS);
|
||||
@@ -11,7 +13,7 @@ export function isAutoLinkedFileRef(href: string, label: string): boolean {
|
||||
if (dotIndex < 1) {
|
||||
return false;
|
||||
}
|
||||
const ext = label.slice(dotIndex + 1).toLowerCase();
|
||||
const ext = normalizeLowercaseStringOrEmpty(label.slice(dotIndex + 1));
|
||||
if (!FILE_REF_EXTENSIONS_WITH_TLD.has(ext)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user