refactor: dedupe provider lowercase helpers

This commit is contained in:
Peter Steinberger
2026-04-07 15:41:05 +01:00
parent 761e12008d
commit bbcc95948e
13 changed files with 47 additions and 26 deletions

View File

@@ -4,6 +4,7 @@ import {
resolveLoggerBackedRuntime,
safeParseJsonWithSchema,
} from "openclaw/plugin-sdk/extension-shared";
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
import { z } from "zod";
import {
WEBHOOK_RATE_LIMIT_DEFAULTS,
@@ -72,7 +73,7 @@ function formatError(err: unknown): string {
function normalizeOrigin(value: string): string | null {
try {
return new URL(value).origin.toLowerCase();
return normalizeLowercaseStringOrEmpty(new URL(value).origin);
} catch {
return null;
}

View File

@@ -1,3 +1,5 @@
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
export function stripNextcloudTalkTargetPrefix(raw: string): string | undefined {
const trimmed = raw.trim();
if (!trimmed) {
@@ -27,7 +29,7 @@ export function stripNextcloudTalkTargetPrefix(raw: string): string | undefined
export function normalizeNextcloudTalkMessagingTarget(raw: string): string | undefined {
const normalized = stripNextcloudTalkTargetPrefix(raw);
return normalized ? `nextcloud-talk:${normalized}`.toLowerCase() : undefined;
return normalized ? normalizeLowercaseStringOrEmpty(`nextcloud-talk:${normalized}`) : undefined;
}
export function looksLikeNextcloudTalkTargetId(raw: string): boolean {