mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[PTRun][ValueGenerator]Add URI/URL features (#30648)
* move existing generator classes * add new generators * implement new generators * fixes * improvements * shorten query tags * make spellcheck happy * add tests * dev docs * fix typos * fix tests
This commit is contained in:
@@ -30,12 +30,23 @@ namespace Community.PowerToys.Run.Plugin.ValueGenerator.UnitTests
|
||||
[DataRow("base99 abc", null)]
|
||||
[DataRow("base64s abc", null)]
|
||||
[DataRow("base64d abc=", typeof(Base64.Base64DecodeRequest))]
|
||||
public void ParserTest(string input, Type? expectedRequestType)
|
||||
[DataRow("url http://googl.de/u oii d", typeof(Uri.UrlEncodeRequest))]
|
||||
[DataRow("urld http://googl.de/u oii d=oo", typeof(Uri.UrlDecodeRequest))]
|
||||
[DataRow("esc:data jjdje332j 3 3l2jl32", typeof(Uri.DataEscapeRequest))]
|
||||
[DataRow("esc:hex d", typeof(Uri.HexEscapeRequest))]
|
||||
[DataRow("esc:hex 4", typeof(Uri.HexEscapeRequest))]
|
||||
[DataRow("esc:hex ", typeof(Uri.HexEscapeRequest), true)]
|
||||
[DataRow("esc:hex z44", typeof(Uri.HexEscapeRequest), true)]
|
||||
[DataRow("uesc:data jjdje332j 3 3l2jl32", typeof(Uri.DataUnescapeRequest))]
|
||||
[DataRow("uesc:hex %21", typeof(Uri.HexUnescapeRequest))]
|
||||
[DataRow("uesc:hex 4", typeof(Uri.HexUnescapeRequest))]
|
||||
[DataRow("uesc:hex ", typeof(Uri.HexUnescapeRequest))]
|
||||
[DataRow("uesc:hex z44", typeof(Uri.HexUnescapeRequest))]
|
||||
public void ParserTest(string input, Type? expectedRequestType, bool expectException = false)
|
||||
{
|
||||
var parser = new InputParser();
|
||||
var query = new Query(input);
|
||||
|
||||
var expectException = false;
|
||||
string? command = null;
|
||||
if (query.Terms.Count == 0)
|
||||
{
|
||||
@@ -79,15 +90,24 @@ namespace Community.PowerToys.Run.Plugin.ValueGenerator.UnitTests
|
||||
private static bool CommandIsKnown(string command)
|
||||
{
|
||||
string[] hashes = new string[] { "md5", "sha1", "sha256", "sha384", "sha512", "base64", "base64d" };
|
||||
|
||||
if (hashes.Contains(command.ToLowerInvariant()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Regex regex = new Regex("^(guid|uuid)([1345]{0,1}|v[1345]{1})$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
Regex regexGuiUUID = new Regex("^(guid|uuid)([1345]{0,1}|v[1345]{1})$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
if (regexGuiUUID.IsMatch(command))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return regex.IsMatch(command);
|
||||
string[] uriCommands = new string[] { "url", "urld", "esc:hex", "uesc:hex", "esc:data", "uesc:data" };
|
||||
if (uriCommands.Contains(command.ToLowerInvariant()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user