Skip to content

Commit

Permalink
修改空字符串可能导致出现异常
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuLing-zhang committed Dec 15, 2024
1 parent db5e5b5 commit 1b122c8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/JiuLing.CommonLibs/Security/Signature/SignatureBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using JiuLing.CommonLibs.ExtensionMethods;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
Expand Down Expand Up @@ -63,6 +64,10 @@ public SignatureBuilder OrderBy()
/// <returns></returns>
public SignatureBuilder FetchParameterValue(string separator = "&")
{
if (_signValue.IsEmpty())
{
return this;
}
var parameterKeyValueList = _signValue.Split('&').ToList();
var parameterValueList = parameterKeyValueList.Select(x => x.Split('=')[1]).ToList();
_signValue = string.Join(separator, parameterValueList);
Expand All @@ -76,6 +81,10 @@ public SignatureBuilder FetchParameterValue(string separator = "&")
/// <returns></returns>
public SignatureBuilder FetchParameterNameAndValue(string separator = "")
{
if (_signValue.IsEmpty())
{
return this;
}
var parameterKeyValueList = _signValue.Split('&').ToList();
parameterKeyValueList = parameterKeyValueList.Select(x => x.Replace("=", "")).ToList();
_signValue = string.Join(separator, parameterKeyValueList);
Expand Down

0 comments on commit 1b122c8

Please sign in to comment.