MCPcopy
hub / github.com/CaliCastle/cali.so / parseDisplayName

Function parseDisplayName

lib/string.ts:1–24  ·  view source on GitHub ↗
({
  firstName,
  lastName,
}: {
  readonly firstName?: string | null
  readonly lastName?: string | null
})

Source from the content-addressed store, hash-verified

1export function parseDisplayName({
2 firstName,
3 lastName,
4}: {
5 readonly firstName?: string | null
6 readonly lastName?: string | null
7}) {
8 if (firstName && lastName) {
9 if (firstName === lastName) {
10 return firstName
11 }
12
13 return `${firstName} ${lastName}`
14 }
15
16 if (firstName) {
17 return firstName
18 }
19 if (lastName) {
20 return lastName
21 }
22
23 return '匿名用户'
24}
25
26export function truncate(str: string, maxLength = 50): string {
27 if (str.length <= maxLength) {

Callers 5

CommentFunction · 0.90
CommentTextareaFunction · 0.90
NewGuestbookEmailFunction · 0.90
NewReplyCommentEmailFunction · 0.90
MessageFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected