From f295d58a6a4f2156dd2eaa169228dc40b9b478cc Mon Sep 17 00:00:00 2001 From: Jaex Date: Thu, 17 Aug 2017 21:45:07 +0300 Subject: [PATCH] Added random syntax support to custom uploader request URL --- .../Helpers/CustomUploaderItem.cs | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/ShareX.UploadersLib/Helpers/CustomUploaderItem.cs b/ShareX.UploadersLib/Helpers/CustomUploaderItem.cs index b4da6bf93..c93d3f147 100644 --- a/ShareX.UploadersLib/Helpers/CustomUploaderItem.cs +++ b/ShareX.UploadersLib/Helpers/CustomUploaderItem.cs @@ -1,4 +1,4 @@ -#region License Information (GPL v3) +#region License Information (GPL v3) /* ShareX - A program that allows you to take screenshots and share any file type @@ -91,7 +91,9 @@ public string GetRequestURL() throw new Exception("'Request URL' must be not empty."); } - return URLHelpers.FixPrefix(RequestURL); + string url = ParseURL(RequestURL, false); + + return URLHelpers.FixPrefix(url); } public string GetFileFormName() @@ -153,7 +155,7 @@ public void ParseResponse(UploadResult result, bool isShortenedURL = false) if (!string.IsNullOrEmpty(URL)) { - url = ParseURL(URL); + url = ParseURL(URL, true); } else { @@ -169,8 +171,8 @@ public void ParseResponse(UploadResult result, bool isShortenedURL = false) result.URL = url; } - result.ThumbnailURL = ParseURL(ThumbnailURL); - result.DeletionURL = ParseURL(DeletionURL); + result.ThumbnailURL = ParseURL(ThumbnailURL, true); + result.DeletionURL = ParseURL(DeletionURL, true); } } @@ -187,7 +189,7 @@ private void ParseRegexList() } } - private string ParseURL(string url) + private string ParseURL(string url, bool output) { if (string.IsNullOrEmpty(url)) { @@ -242,23 +244,28 @@ private string ParseURL(string url) if (!string.IsNullOrEmpty(parseText)) { - string resultText; + string resultText = null; - switch (parseType) + if (output) { - default: - case CustomUploaderResponseParseType.Regex: - resultText = ParseRegexSyntax(parseText); - break; - case CustomUploaderResponseParseType.Json: - resultText = ParseJsonSyntax(parseText); - break; - case CustomUploaderResponseParseType.Xml: - resultText = ParseXmlSyntax(parseText); - break; - case CustomUploaderResponseParseType.Random: - resultText = ParseRandomSyntax(parseText); - break; + switch (parseType) + { + default: + case CustomUploaderResponseParseType.Regex: + resultText = ParseRegexSyntax(parseText); + break; + case CustomUploaderResponseParseType.Json: + resultText = ParseJsonSyntax(parseText); + break; + case CustomUploaderResponseParseType.Xml: + resultText = ParseXmlSyntax(parseText); + break; + } + } + + if (parseType == CustomUploaderResponseParseType.Random) + { + resultText = ParseRandomSyntax(parseText); } if (!string.IsNullOrEmpty(resultText))