diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-27 00:55:15 +0100 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-29 15:56:48 +0200 |
| commit | 4d127a038bf768eded68aae3cfa5c1b12241bdac (patch) | |
| tree | 16bbb801caf6770546cff4fdb37b6408ec9ead98 /apps/web/src/lib/stickers/sticker-id.ts | |
| parent | 82817cb50cb0487350573d6129130aec705f924b (diff) | |
| download | opencut-4d127a038bf768eded68aae3cfa5c1b12241bdac.tar.gz | |
chore: normalize line endings
Diffstat (limited to 'apps/web/src/lib/stickers/sticker-id.ts')
| -rw-r--r-- | apps/web/src/lib/stickers/sticker-id.ts | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/apps/web/src/lib/stickers/sticker-id.ts b/apps/web/src/lib/stickers/sticker-id.ts index 8cb9364b..cb56db4c 100644 --- a/apps/web/src/lib/stickers/sticker-id.ts +++ b/apps/web/src/lib/stickers/sticker-id.ts @@ -1,34 +1,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}`; -} +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}`;
+}
|
