Sam Therapy
e2ec4a5857
Some checks failed
continuous-integration/drone Build is failing
also prepare pipelines and stuff Signed-off-by: Sam Therapy <sam@samtherapy.net>
31 lines
741 B
C#
31 lines
741 B
C#
using System;
|
|
using System.Text.RegularExpressions;
|
|
|
|
using BirdsiteLive.Domain.Repository;
|
|
|
|
using Org.BouncyCastle.Pkcs;
|
|
|
|
namespace BirdsiteLive.Domain.Tools
|
|
{
|
|
public class ModerationRegexParser
|
|
{
|
|
public static Regex Parse(ModerationEntityTypeEnum type, string data)
|
|
{
|
|
data = data.ToLowerInvariant().Trim();
|
|
|
|
if (type == ModerationEntityTypeEnum.Follower)
|
|
{
|
|
if (data.StartsWith("@"))
|
|
return new Regex($@"^{data}$");
|
|
|
|
if (data.StartsWith("*"))
|
|
data = data.Replace("*", "(.+)");
|
|
|
|
return new Regex($@"^@(.+)@{data}$");
|
|
}
|
|
|
|
return new Regex($@"^{data}$");
|
|
}
|
|
}
|
|
}
|