summaryrefslogtreecommitdiffstats
path: root/src/lib/search/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/search/utils.ts')
-rw-r--r--src/lib/search/utils.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/search/utils.ts b/src/lib/search/utils.ts
new file mode 100644
index 0000000..d6b6aa8
--- /dev/null
+++ b/src/lib/search/utils.ts
@@ -0,0 +1,17 @@
+/**
+ * Formats a source name to lowercase with dots instead of spaces
+ */
+export function formatSourceName(sourceName: string): string {
+ return sourceName.toLowerCase().replace(/\s+/g, '.');
+}
+
+/**
+ * Finds a source by its formatted name from available sources
+ */
+export function findSourceByFormattedName(
+ formattedName: string,
+ availableSources: string[]
+): string {
+ if (formattedName === 'all') return 'all';
+ return availableSources.find((source) => formatSourceName(source) === formattedName) ?? 'all';
+}