mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-26 18:28:27 +02:00
* Lower priority from Proxy mappings * Fix codefactor * extra tests * #205 * Fix test for linux * `c:\temp\x.json` fix * Extra tests * more tests * more tests * codefactor * #200 * refactor * refactor * tests
This commit is contained in:
@@ -9,7 +9,7 @@ namespace WireMock.Util
|
||||
/// </summary>
|
||||
public static class PortUtils
|
||||
{
|
||||
private static readonly Regex UrlDetailsRegex = new Regex(@"^(?<proto>\w+)://[^/]+?(?<port>\d+)/?", RegexOptions.Compiled);
|
||||
private static readonly Regex UrlDetailsRegex = new Regex(@"^((?<proto>\w+)://)(?<host>[^/]+?):(?<port>\d+)\/?$", RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// Finds a free TCP port.
|
||||
@@ -32,17 +32,19 @@ namespace WireMock.Util
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract a proto and port from a URL.
|
||||
/// Extract the protocol, host and port from a URL.
|
||||
/// </summary>
|
||||
public static bool TryExtractProtocolAndPort(string url, out string proto, out int port)
|
||||
public static bool TryExtract(string url, out string protocol, out string host, out int port)
|
||||
{
|
||||
proto = null;
|
||||
port = 0;
|
||||
protocol = null;
|
||||
host = null;
|
||||
port = default(int);
|
||||
|
||||
Match m = UrlDetailsRegex.Match(url);
|
||||
if (m.Success)
|
||||
{
|
||||
proto = m.Groups["proto"].Value;
|
||||
protocol = m.Groups["proto"].Value;
|
||||
host = m.Groups["host"].Value;
|
||||
|
||||
return int.TryParse(m.Groups["port"].Value, out port);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace WireMock.Utils
|
||||
namespace WireMock.Util
|
||||
{
|
||||
internal static class RegexUtils
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user