Skip to content

Commit

Permalink
fixing cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
azhe403 committed Jun 2, 2024
1 parent e6739ab commit bfbe196
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/ZiziBot.Utils/StringUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public static string ForCacheKey(this string url)
.Replace("https://", "")
.Replace("http://", "")
.Replace(".", "-")
.RegexReplaceEval(@"(%20|\s)+", "_")
.TrimEnd('_');

return key;
Expand Down Expand Up @@ -167,6 +168,16 @@ public static string RegexReplace(this string input, string pattern, string repl
return Regex.Replace(input, pattern, replacement);
}

public static string RegexReplaceEval(this string input, string pattern, string replacement)
{
return Regex.Replace(input, pattern, Eval);

string Eval(Match m)
{
return replacement;
}
}

public static string RegexMatch(this string input, string pattern)
{
return Regex.Match(input, pattern).Value;
Expand Down

0 comments on commit bfbe196

Please sign in to comment.