parseCustomId
Function: parseCustomId()
Section titled “Function: parseCustomId()”Call Signature
Section titled “Call Signature”parseCustomId(
customId,onlyPrefix):string
Defined in: utils/index.ts:33
Parse a custom ID string into its parts.
Supports two modes:
- onlyPrefix = true: returns the prefix string before the first ‘/’ or ‘?’.
- onlyPrefix = false (default): returns an object with parsed pieces.
Expected customId shapes:
- “prefix/component/other/path?param1/param2”
- “prefix?param1/param2”
Parameters
Section titled “Parameters”customId
Section titled “customId”string
The custom ID to parse.
onlyPrefix
Section titled “onlyPrefix”true
If true, only return the prefix string (default: false).
Returns
Section titled “Returns”string
If onlyPrefix is true: string (the prefix). Otherwise an object with:
- compPath: string[] (full path split by ‘/’),
- prefix: string (first item of compPath),
- lastPathItem: string (last item of compPath),
- component: string | null (second item of compPath or null),
- params: string[] (params split by ‘/’; empty array when none),
- firstParam: string | null,
- lastParam: string | null
Example
Section titled “Example”parseCustomId("modal/user/profile?123/abc")// => { compPath: ["modal","user","profile"], prefix: "modal", ... params: ["123","abc"], ... }
parseCustomId("button/click", true)// => "button"Call Signature
Section titled “Call Signature”parseCustomId(
customId,onlyPrefix?):object
Defined in: utils/index.ts:34
Parse a custom ID string into its parts.
Supports two modes:
- onlyPrefix = true: returns the prefix string before the first ‘/’ or ‘?’.
- onlyPrefix = false (default): returns an object with parsed pieces.
Expected customId shapes:
- “prefix/component/other/path?param1/param2”
- “prefix?param1/param2”
Parameters
Section titled “Parameters”customId
Section titled “customId”string
The custom ID to parse.
onlyPrefix?
Section titled “onlyPrefix?”false
If true, only return the prefix string (default: false).
Returns
Section titled “Returns”object
If onlyPrefix is true: string (the prefix). Otherwise an object with:
- compPath: string[] (full path split by ‘/’),
- prefix: string (first item of compPath),
- lastPathItem: string (last item of compPath),
- component: string | null (second item of compPath or null),
- params: string[] (params split by ‘/’; empty array when none),
- firstParam: string | null,
- lastParam: string | null
component
Section titled “component”component:
string|null
compPath
Section titled “compPath”compPath:
string[]
firstParam
Section titled “firstParam”firstParam:
string|null
lastParam
Section titled “lastParam”lastParam:
string|null
lastPathItem
Section titled “lastPathItem”lastPathItem:
string
params
Section titled “params”params:
string[]
prefix
Section titled “prefix”prefix:
string
Example
Section titled “Example”parseCustomId("modal/user/profile?123/abc")// => { compPath: ["modal","user","profile"], prefix: "modal", ... params: ["123","abc"], ... }
parseCustomId("button/click", true)// => "button"