blob: d6b6aa8a2c4464055b2e0b17e59bf57ddb4ca9f6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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';
}
|