Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add pluralize utility function for dynamic word forms

Nabaruna093453745fa
diff --git a/apps/web/lib/analytics/utils.ts b/apps/web/lib/analytics/utils.ts
index 21c527d642..ad5a4227a1 100644
--- a/apps/web/lib/analytics/utils.ts
+++ b/apps/web/lib/analytics/utils.ts
@@ -86,3 +86,20 @@ export const convertToCSV = (data: object[]) => {
},
});
};
+
+type PluralizeOptions = {
+ plural?: string;
+}
+
+export const pluralize = (
+ word: string,
+ count: number,
+ options: PluralizeOptions = {}
+) => {
+ if (count === 1) {
+ return word;
+ }
+
+ // Use custom plural form if provided, otherwise add 's'
+ return options.plural || `${word}s`;
+};