private Regex BuildRegexByLocationWithKey(SecureLocationType locationType, string secureKey) { switch (locationType) { case SecureLocationType.Rest: return(new Regex(@$ "(?<{KeyGroupName}>/{secureKey}/)(?<{ValueGroupName}>[^/?]*)")); case SecureLocationType.Query: return(new Regex($@"(?<{KeyGroupName}>(\?|\&){secureKey}=)(?<{ValueGroupName}>[^\&]*)")); default: throw new NotImplementedException($"SecureLocation: {locationType.ToString()}"); } }
public string ClearSecure(string url, string secureKey, SecureLocationType locationType) { var regex = BuildRegexByLocationWithKey(locationType, secureKey); return(regex.Replace(url, EncodeSecureData)); }