mirror of
https://github.com/ShareX/ShareX.git
synced 2024-06-30 20:20:34 +12:00
Removed regex list instead using first parameter for regex pattern
This commit is contained in:
parent
1b0262ce4f
commit
57972d07cb
|
@ -269,7 +269,6 @@ public void ParseResponse(UploadResult result, ResponseInfo responseInfo, Custom
|
|||
{
|
||||
FileName = input.FileName,
|
||||
ResponseInfo = responseInfo,
|
||||
RegexList = RegexList,
|
||||
URLEncode = true
|
||||
};
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ public class CustomUploaderSyntaxParser : ShareXSyntaxParser
|
|||
public string FileName { get; set; }
|
||||
public string Input { get; set; }
|
||||
public ResponseInfo ResponseInfo { get; set; }
|
||||
public List<string> RegexList { get; set; }
|
||||
public bool URLEncode { get; set; } // Only URL encodes file name and input
|
||||
public bool JSONEncode { get; set; }
|
||||
public bool XMLEncode { get; set; }
|
||||
|
|
|
@ -35,26 +35,33 @@ public override string Call(CustomUploaderSyntaxParser parser, string[] paramete
|
|||
{
|
||||
if (parameters.Length > 0)
|
||||
{
|
||||
string regexIndex = parameters[0];
|
||||
string pattern = parameters[0];
|
||||
|
||||
if (!string.IsNullOrEmpty(regexIndex) && int.TryParse(regexIndex, out int regexIndexNumber))
|
||||
if (!string.IsNullOrEmpty(pattern))
|
||||
{
|
||||
string pattern = parser.RegexList[regexIndexNumber - 1];
|
||||
Match match = Regex.Match(parser.ResponseInfo.ResponseText, pattern);
|
||||
|
||||
if (parameters.Length > 1)
|
||||
if (match.Success)
|
||||
{
|
||||
string regexGroup = parameters[1];
|
||||
|
||||
if (!string.IsNullOrEmpty(regexGroup) && int.TryParse(regexGroup, out int regexGroupNumber))
|
||||
if (parameters.Length > 1)
|
||||
{
|
||||
return match.Groups[regexGroupNumber].Value;
|
||||
string group = parameters[1];
|
||||
|
||||
if (!string.IsNullOrEmpty(group))
|
||||
{
|
||||
if (int.TryParse(group, out int groupNumber))
|
||||
{
|
||||
return match.Groups[groupNumber].Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return match.Groups[group].Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return match.Groups[regexGroup].Value;
|
||||
return match.Value;
|
||||
}
|
||||
|
||||
return match.Value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue