mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Removed custom uploader response type option, added backward compatibility for it
This commit is contained in:
parent
ba29dc918b
commit
b19e0ee83c
4 changed files with 42 additions and 7 deletions
|
@ -86,8 +86,7 @@ public bool ShouldSerializeArguments() => (Body == CustomUploaderBody.MultipartF
|
|||
public bool ShouldSerializeData() => (Body == CustomUploaderBody.JSON || Body == CustomUploaderBody.XML) && !string.IsNullOrEmpty(Data);
|
||||
|
||||
// For backward compatibility
|
||||
[DefaultValue(ResponseType.Text)]
|
||||
public ResponseType ResponseType { get; set; }
|
||||
public ResponseType ResponseType { private get; set; }
|
||||
|
||||
[DefaultValue(null)]
|
||||
public List<string> RegexList { get; set; }
|
||||
|
@ -294,6 +293,35 @@ public void CheckBackwardCompatibility()
|
|||
Arguments = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (ResponseType == ResponseType.RedirectionURL)
|
||||
{
|
||||
if (string.IsNullOrEmpty(URL))
|
||||
{
|
||||
URL = "$responseurl$";
|
||||
}
|
||||
|
||||
URL = URL.Replace("$response$", "$responseurl$");
|
||||
ThumbnailURL = ThumbnailURL?.Replace("$response$", "$responseurl$");
|
||||
DeletionURL = DeletionURL?.Replace("$response$", "$responseurl$");
|
||||
}
|
||||
else if (ResponseType == ResponseType.Headers)
|
||||
{
|
||||
URL = "Response type option is deprecated, please use \\$header:header_name\\$ syntax instead.";
|
||||
}
|
||||
else if (ResponseType == ResponseType.LocationHeader)
|
||||
{
|
||||
if (string.IsNullOrEmpty(URL))
|
||||
{
|
||||
URL = "$header:Location$";
|
||||
}
|
||||
|
||||
URL = URL.Replace("$response$", "$header:Location$");
|
||||
ThumbnailURL = ThumbnailURL?.Replace("$response$", "$header:Location$");
|
||||
DeletionURL = DeletionURL?.Replace("$response$", "$header:Location$");
|
||||
}
|
||||
|
||||
ResponseType = ResponseType.Text;
|
||||
}
|
||||
|
||||
Version = Application.ProductVersion;
|
||||
|
|
|
@ -205,9 +205,9 @@ private string ParseSyntax(string syntax, bool isOutput)
|
|||
{
|
||||
return ResponseInfo.ResponseURL;
|
||||
}
|
||||
else if (ResponseInfo.Headers != null && CheckKeyword(syntax, "header", out value)) // Example: $header:Location$
|
||||
else if (CheckKeyword(syntax, "header", out value)) // Example: $header:Location$
|
||||
{
|
||||
return ResponseInfo.Headers[value];
|
||||
return ParseSyntaxHeader(value);
|
||||
}
|
||||
else if (CheckKeyword(syntax, "regex", out value)) // Examples: $regex:1$ $regex:1|1$ $regex:1|thumbnail$
|
||||
{
|
||||
|
@ -287,6 +287,16 @@ private bool CheckKeyword(string syntax, string keyword, out string value)
|
|||
return false;
|
||||
}
|
||||
|
||||
private string ParseSyntaxHeader(string header)
|
||||
{
|
||||
if (ResponseInfo.Headers != null)
|
||||
{
|
||||
return ResponseInfo.Headers[header];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string ParseSyntaxRegex(string syntax)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(syntax))
|
||||
|
|
|
@ -3863,8 +3863,6 @@ private void lvCustomUploaderHeaders_SelectedIndexChanged(object sender, EventAr
|
|||
|
||||
private void cbCustomUploaderResponseType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CustomUploaderItem uploader = CustomUploaderGetSelected();
|
||||
if (uploader != null) uploader.ResponseType = (ResponseType)cbCustomUploaderResponseType.SelectedIndex;
|
||||
}
|
||||
|
||||
private void txtCustomUploaderJsonPath_TextChanged(object sender, EventArgs e)
|
||||
|
|
|
@ -1007,7 +1007,6 @@ private void CustomUploaderLoad(CustomUploaderItem uploader)
|
|||
}
|
||||
}
|
||||
|
||||
cbCustomUploaderResponseType.SelectedIndex = (int)uploader.ResponseType;
|
||||
txtCustomUploaderJsonPath.Text = "";
|
||||
txtCustomUploaderXPath.Text = "";
|
||||
txtCustomUploaderRegexp.Text = "";
|
||||
|
|
Loading…
Reference in a new issue