fix: Fix missing hyphen character on regex for parsing reddit entity name

Reddit users can have hyphens in their names. Slight tradeoff for allowing hyphens for subreddit names (they are non existent) to allow all valid reddit user names is worth it.

Found and corrected by @prometheus-22
This commit is contained in:
FoxxMD
2021-12-31 00:04:25 -05:00
parent acb72551ec
commit bbb4ec3c2d

View File

@@ -611,7 +611,7 @@ export const parseSubredditName = (val:string): string => {
return matches[1] as string;
}
export const REDDIT_ENTITY_REGEX: RegExp = /^\s*(?<entityType>\/[ru]\/|[ru]\/|u_)*(?<name>\w+)*\s*$/;
export const REDDIT_ENTITY_REGEX: RegExp = /^\s*(?<entityType>\/[ru]\/|[ru]\/|u_)*(?<name>[\w-]+)*\s*$/;
export const REDDIT_ENTITY_REGEX_URL = 'https://regexr.com/6bq1g';
export const parseRedditEntity = (val:string, defaultUndefinedPrefix: RedditEntityType = 'subreddit'): RedditEntity => {
if(val.trim().length === 0) {