mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-27 10:47:01 +02:00
Add Custom Certificate settings (#537)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user