blob: cb56db4cdb61736457461a2508e6ce7b6e2707fa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
export function parseStickerId({ stickerId }: { stickerId: string }): {
providerId: string;
providerValue: string;
} {
const normalizedStickerId = stickerId.trim();
if (!normalizedStickerId) {
throw new Error("Sticker ID must be a non-empty string");
}
const separatorIndex = normalizedStickerId.indexOf(":");
if (
separatorIndex <= 0 ||
separatorIndex === normalizedStickerId.length - 1
) {
throw new Error(
`Invalid sticker ID format: "${stickerId}". Expected "provider:value".`,
);
}
const providerId = normalizedStickerId.slice(0, separatorIndex).trim();
const providerValue = normalizedStickerId.slice(separatorIndex + 1).trim();
return { providerId, providerValue };
}
export function buildStickerId({
providerId,
providerValue,
}: {
providerId: string;
providerValue: string;
}): string {
return `${providerId}:${providerValue}`;
}
|