mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-15 23:03:55 +01:00
* Add TIOBE + include SonarAnalyzer.CSharp * . * cp * Copyright © WireMock.Net * more fixes * fix * xpath * if (Matchers == null || !Matchers.Any()) * if (Matchers != null) * ? * . * .
31 lines
700 B
C#
31 lines
700 B
C#
// Copyright © WireMock.Net
|
|
|
|
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}";
|
|
}
|
|
} |