Add Custom Certificate settings (#537)

This commit is contained in:
Stef Heyenrath
2020-11-10 15:40:15 +00:00
committed by GitHub
parent a0fdc002c8
commit 09533f1e3a
24 changed files with 478 additions and 103 deletions

View File

@@ -1,4 +1,5 @@
using System.Net;
using System;
using System.Net;
using System.Net.Sockets;
using System.Text.RegularExpressions;
@@ -32,21 +33,23 @@ namespace WireMock.Util
}
/// <summary>
/// Extract the protocol, host and port from a URL.
/// Extract the if-isHttps, protocol, host and port from a URL.
/// </summary>
public static bool TryExtract(string url, out string protocol, out string host, out int port)
public static bool TryExtract(string url, out bool isHttps, out string protocol, out string host, out int port)
{
isHttps = false;
protocol = null;
host = null;
port = default(int);
port = default;
Match m = UrlDetailsRegex.Match(url);
if (m.Success)
var match = UrlDetailsRegex.Match(url);
if (match.Success)
{
protocol = m.Groups["proto"].Value;
host = m.Groups["host"].Value;
protocol = match.Groups["proto"].Value;
isHttps = protocol.StartsWith("https", StringComparison.OrdinalIgnoreCase);
host = match.Groups["host"].Value;
return int.TryParse(m.Groups["port"].Value, out port);
return int.TryParse(match.Groups["port"].Value, out port);
}
return false;