mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-29 10:02:04 +00:00
refactor: dedupe primary string helpers
This commit is contained in:
@@ -14,6 +14,16 @@ export function normalizeOptionalString(value: unknown): string | undefined {
|
||||
return normalizeNullableString(value) ?? undefined;
|
||||
}
|
||||
|
||||
export function resolvePrimaryStringValue(value: unknown): string | undefined {
|
||||
if (typeof value === "string") {
|
||||
return normalizeOptionalString(value);
|
||||
}
|
||||
if (!value || typeof value !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
return normalizeOptionalString((value as { primary?: unknown }).primary);
|
||||
}
|
||||
|
||||
export function hasNonEmptyString(value: unknown): value is string {
|
||||
return normalizeOptionalString(value) !== undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user