mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-05 22:35:17 -04:00
OpenID Connect support (#3975)
Co-authored-by: DieselTech <30128380+DieselTech@users.noreply.github.com> Co-authored-by: majora2007 <josephmajora@gmail.com>
This commit is contained in:
@@ -52,4 +52,33 @@ public static class StringExtensions
|
||||
{
|
||||
return string.IsNullOrEmpty(value) ? defaultValue : double.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static string TrimPrefix(this string? value, string prefix)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return string.Empty;
|
||||
|
||||
if (!value.StartsWith(prefix)) return value;
|
||||
|
||||
return value.Substring(prefix.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Censor the input string by removing all but the first and last char.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>If the input is an email (contains @), the domain will remain untouched</remarks>
|
||||
public static string Censor(this string? input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input)) return input ?? string.Empty;
|
||||
|
||||
var atIdx = input.IndexOf('@');
|
||||
if (atIdx == -1)
|
||||
{
|
||||
return $"{input[0]}{new string('*', input.Length - 1)}";
|
||||
}
|
||||
|
||||
return input[0] + new string('*', atIdx - 1) + input[atIdx..];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user