using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
public static class ClipboardFusionHelper
{
private static Regex jwtTokenPattern = new Regex("^ey[A-Z0-9a-z\\+/]+?\\.(ey[A-Z0-9a-z\\+/]+?)\\.", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.Singleline);
public static string ProcessText(string text)
{
if (!text.StartsWith("ey") || text.IndexOf(".ey") <= 0)
return text;
var match = jwtTokenPattern.Match(text);
if (!match.Success)
return text;
try
{
var token = match.Groups[1].Value;
switch (token.Length % 4)
{
case 1:
token += "===";
break;
case 2:
token += "==";
break;
case 3:
token += "=";
break;
}
return System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(token));
}
catch
{
return text;
}
}
}