Files
sim/apps/sim/tools/reddit/utils.ts
Vikhyath Mondreti bf8fbebe22 improvement(code-quality): centralize regex checks, normalization (#2554)
* improvement(code-quality): centralize regex checks, normalization

* simplify resolution

* fix(copilot): don't allow duplicate name blocks

* centralize uuid check
2025-12-23 15:12:04 -08:00

11 lines
378 B
TypeScript

const SUBREDDIT_PREFIX = /^r\//
/**
* Normalizes a subreddit name by removing the 'r/' prefix if present and trimming whitespace.
* @param subreddit - The subreddit name to normalize
* @returns The normalized subreddit name without the 'r/' prefix
*/
export function normalizeSubreddit(subreddit: string): string {
return subreddit.trim().replace(SUBREDDIT_PREFIX, '')
}