MCPcopy Create free account
hub / github.com/cloudflare/wildebeest / parseHandle

Function parseHandle

backend/src/utils/parse.ts:7–28  ·  view source on GitHub ↗
(query: string)

Source from the content-addressed store, hash-verified

5
6// Parse a "handle" in the form: `[@] <local-part> '@' <domain>`
7export function parseHandle(query: string): Handle {
8 // Remove the leading @, if there's one.
9 if (query.startsWith('@')) {
10 query = query.substring(1)
11 }
12
13 // In case the handle has been URL encoded
14 query = decodeURIComponent(query)
15
16 const parts = query.split('@')
17 const localPart = parts[0]
18
19 if (!/^[\w-.]+$/.test(localPart)) {
20 throw new Error('invalid handle: localPart: ' + localPart)
21 }
22
23 if (parts.length > 1) {
24 return { localPart, domain: parts[1] }
25 } else {
26 return { localPart, domain: null }
27 }
28}

Callers 15

useAccountIsLocalFunction · 0.90
index.tsxFile · 0.90
index.tsxFile · 0.90
utils.spec.tsFile · 0.90
getAccountFunction · 0.90
addAliasFunction · 0.90
handleFunction · 0.90
getMentionsFunction · 0.90
getMentionSpanFunction · 0.90
handleRequestFunction · 0.90
handleRequestFunction · 0.90
handleRequestFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected