mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-14 14:27:41 +01:00
* r * fix * sw * x * s * . * . * . * CreateTypeFromJObject * . * . * f * c * . * . * . * . * . * . * ok * , * . * . * . * . * n * pact * fix * schema * null * fluent * r * -p * . * . * refs * .
29 lines
670 B
C#
29 lines
670 B
C#
using System.Linq;
|
|
using WireMock.Admin.Mappings;
|
|
|
|
namespace WireMock.Extensions;
|
|
|
|
public static class RequestModelExtensions
|
|
{
|
|
public static string? GetPathAsString(this RequestModel request)
|
|
{
|
|
var path = request.Path switch
|
|
{
|
|
string pathAsString => pathAsString,
|
|
PathModel pathModel => pathModel.Matchers?.FirstOrDefault()?.Pattern as string,
|
|
_ => null
|
|
};
|
|
|
|
return FixPath(path);
|
|
}
|
|
|
|
private static string? FixPath(string? path)
|
|
{
|
|
if (string.IsNullOrEmpty(path))
|
|
{
|
|
return path;
|
|
}
|
|
|
|
return path!.StartsWith("/") ? path : $"/{path}";
|
|
}
|
|
} |