mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added input parameter support to custom uploader xml function
This commit is contained in:
parent
d46e40ce53
commit
17a6fc878d
3 changed files with 20 additions and 6 deletions
|
@ -40,9 +40,9 @@ public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] pa
|
|||
// https://goessner.net/articles/JsonPath/
|
||||
string input, jsonPath;
|
||||
|
||||
// {json:input|jsonPath}
|
||||
if (parameters.Length > 1)
|
||||
{
|
||||
// {json:input|jsonPath}
|
||||
input = parameters[0];
|
||||
jsonPath = parameters[1];
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] pa
|
|||
{
|
||||
string input, pattern, group = "";
|
||||
|
||||
// {regex:input|pattern|group}
|
||||
if (parameters.Length > 2)
|
||||
{
|
||||
// {regex:input|pattern|group}
|
||||
input = parameters[0];
|
||||
pattern = parameters[1];
|
||||
group = parameters[2];
|
||||
|
@ -54,9 +54,9 @@ public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] pa
|
|||
input = parser.ResponseInfo.ResponseText;
|
||||
pattern = parameters[0];
|
||||
|
||||
// {regex:pattern|group}
|
||||
if (parameters.Length > 1)
|
||||
{
|
||||
// {regex:pattern|group}
|
||||
group = parameters[1];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ You should have received a copy of the GNU General Public License
|
|||
namespace ShareX.UploadersLib
|
||||
{
|
||||
// Example: {xml:/files/file[1]/url}
|
||||
// Example: {xml:{response}|/files/file[1]/url}
|
||||
internal class CustomUploaderFunctionXml : CustomUploaderFunction
|
||||
{
|
||||
public override string Name { get; } = "xml";
|
||||
|
@ -38,11 +39,24 @@ internal class CustomUploaderFunctionXml : CustomUploaderFunction
|
|||
public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] parameters)
|
||||
{
|
||||
// https://www.w3schools.com/xml/xpath_syntax.asp
|
||||
string xpath = parameters[0];
|
||||
string input, xpath;
|
||||
|
||||
if (!string.IsNullOrEmpty(xpath))
|
||||
if (parameters.Length > 1)
|
||||
{
|
||||
using (StringReader sr = new StringReader(parser.ResponseInfo.ResponseText))
|
||||
// {xml:input|xpath}
|
||||
input = parameters[0];
|
||||
xpath = parameters[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// {xml:xpath}
|
||||
input = parser.ResponseInfo.ResponseText;
|
||||
xpath = parameters[0];
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(input) && !string.IsNullOrEmpty(xpath))
|
||||
{
|
||||
using (StringReader sr = new StringReader(input))
|
||||
{
|
||||
XPathDocument doc = new XPathDocument(sr);
|
||||
XPathNavigator nav = doc.CreateNavigator();
|
||||
|
|
Loading…
Reference in a new issue