@@ -6,14 +6,10 @@ import {
66 resolveServicePrefixedAllowTarget ,
77 resolveServicePrefixedTarget ,
88} from "openclaw/plugin-sdk/channel-targets" ;
9-
10- function normalizeOptionalString ( value : unknown ) : string | undefined {
11- if ( typeof value !== "string" ) {
12- return undefined ;
13- }
14- const trimmed = value . trim ( ) ;
15- return trimmed || undefined ;
16- }
9+ import {
10+ normalizeLowercaseStringOrEmpty ,
11+ normalizeOptionalString ,
12+ } from "openclaw/plugin-sdk/text-runtime" ;
1713
1814export type BlueBubblesService = "imessage" | "sms" | "auto" ;
1915
@@ -66,7 +62,7 @@ function stripBlueBubblesPrefix(value: string): string {
6662 if ( ! trimmed ) {
6763 return "" ;
6864 }
69- if ( ! trimmed . toLowerCase ( ) . startsWith ( "bluebubbles:" ) ) {
65+ if ( ! normalizeLowercaseStringOrEmpty ( trimmed ) . startsWith ( "bluebubbles:" ) ) {
7066 return trimmed ;
7167 }
7268 return trimmed . slice ( "bluebubbles:" . length ) . trim ( ) ;
@@ -122,7 +118,7 @@ export function normalizeBlueBubblesHandle(raw: string): string {
122118 if ( ! trimmed ) {
123119 return "" ;
124120 }
125- const lowered = trimmed . toLowerCase ( ) ;
121+ const lowered = normalizeLowercaseStringOrEmpty ( trimmed ) ;
126122 if ( lowered . startsWith ( "imessage:" ) ) {
127123 return normalizeBlueBubblesHandle ( trimmed . slice ( 9 ) ) ;
128124 }
@@ -133,7 +129,7 @@ export function normalizeBlueBubblesHandle(raw: string): string {
133129 return normalizeBlueBubblesHandle ( trimmed . slice ( 5 ) ) ;
134130 }
135131 if ( trimmed . includes ( "@" ) ) {
136- return trimmed . toLowerCase ( ) ;
132+ return normalizeLowercaseStringOrEmpty ( trimmed ) ;
137133 }
138134 return trimmed . replace ( / \s + / g, "" ) ;
139135}
@@ -204,7 +200,7 @@ export function looksLikeBlueBubblesTargetId(raw: string, normalized?: string):
204200 if ( parseRawChatGuid ( candidate ) ) {
205201 return true ;
206202 }
207- const lowered = candidate . toLowerCase ( ) ;
203+ const lowered = normalizeLowercaseStringOrEmpty ( candidate ) ;
208204 if ( / ^ ( i m e s s a g e | s m s | a u t o ) : / . test ( lowered ) ) {
209205 return true ;
210206 }
@@ -234,7 +230,7 @@ export function looksLikeBlueBubblesTargetId(raw: string, normalized?: string):
234230 if ( ! normalizedTrimmed ) {
235231 return false ;
236232 }
237- const normalizedLower = normalizedTrimmed . toLowerCase ( ) ;
233+ const normalizedLower = normalizeLowercaseStringOrEmpty ( normalizedTrimmed ) ;
238234 if (
239235 / ^ ( i m e s s a g e | s m s | a u t o ) : / . test ( normalizedLower ) ||
240236 / ^ ( c h a t _ i d | c h a t _ g u i d | c h a t _ i d e n t i f i e r ) : / . test ( normalizedLower )
@@ -254,7 +250,7 @@ export function looksLikeBlueBubblesExplicitTargetId(raw: string, normalized?: s
254250 if ( ! candidate ) {
255251 return false ;
256252 }
257- const lowered = candidate . toLowerCase ( ) ;
253+ const lowered = normalizeLowercaseStringOrEmpty ( candidate ) ;
258254 if ( / ^ ( i m e s s a g e | s m s | a u t o ) : / . test ( lowered ) ) {
259255 return true ;
260256 }
@@ -273,7 +269,7 @@ export function looksLikeBlueBubblesExplicitTargetId(raw: string, normalized?: s
273269 if ( ! normalizedTrimmed ) {
274270 return false ;
275271 }
276- const normalizedLower = normalizedTrimmed . toLowerCase ( ) ;
272+ const normalizedLower = normalizeLowercaseStringOrEmpty ( normalizedTrimmed ) ;
277273 if (
278274 / ^ ( i m e s s a g e | s m s | a u t o ) : / . test ( normalizedLower ) ||
279275 / ^ ( c h a t _ i d | c h a t _ g u i d | c h a t _ i d e n t i f i e r ) : / . test ( normalizedLower )
@@ -307,7 +303,7 @@ export function parseBlueBubblesTarget(raw: string): BlueBubblesTarget {
307303 if ( ! trimmed ) {
308304 throw new Error ( "BlueBubbles target is required" ) ;
309305 }
310- const lower = trimmed . toLowerCase ( ) ;
306+ const lower = normalizeLowercaseStringOrEmpty ( trimmed ) ;
311307
312308 const servicePrefixed = resolveServicePrefixedTarget ( {
313309 trimmed,
@@ -358,7 +354,7 @@ export function parseBlueBubblesAllowTarget(raw: string): BlueBubblesAllowTarget
358354 if ( ! trimmed ) {
359355 return { kind : "handle" , handle : "" } ;
360356 }
361- const lower = trimmed . toLowerCase ( ) ;
357+ const lower = normalizeLowercaseStringOrEmpty ( trimmed ) ;
362358
363359 const servicePrefixed = resolveServicePrefixedAllowTarget ( {
364360 trimmed,
0 commit comments