diff --git a/src/toOpenAIMessages.ts b/src/toOpenAIMessages.ts index b0f2ea9..b1a432d 100644 --- a/src/toOpenAIMessages.ts +++ b/src/toOpenAIMessages.ts @@ -72,8 +72,8 @@ function formatName(name: string): string { .replace(/[^a-zA-Z0-9_-]/g, "_") // remove trailing '-_' characters .replace(/^[-_]+|[-_]+$/g, "") - // remove duplicated '-_' characters - .replace(/([-_])*/g, "$1"); + // remove duplicated '-_' character sequences + .replace(/([-_])([-_])+/g, "$1"); } /**