Files
WireMock.Net/src/WireMock.Net/Util/UrlUtils.cs
Stef Heyenrath a9c0c6b670 Support running WireMock.Net as a sub-app in IIS (#164) (#158)
* Update examples (#158)

* IIS debug

* PathBase logic

* 1.0.4.5-preview-01

* Fix project and readme

* Fix issues

* fix picture alignment

* Add IIS publish examples

* 1.0.4.5
2018-07-17 08:20:44 +02:00

39 lines
913 B
C#

using System;
using JetBrains.Annotations;
using WireMock.Models;
#if !NETSTANDARD
using Microsoft.Owin;
#else
using Microsoft.AspNetCore.Http;
#endif
namespace WireMock.Util
{
internal static class UrlUtils
{
public static UrlDetails Parse([NotNull] Uri uri, PathString pathBase)
{
if (!pathBase.HasValue)
{
return new UrlDetails(uri, uri);
}
var builder = new UriBuilder(uri);
builder.Path = RemoveFirst(builder.Path, pathBase.Value);
return new UrlDetails(uri, builder.Uri);
}
private static string RemoveFirst(string text, string search)
{
int pos = text.IndexOf(search);
if (pos < 0)
{
return text;
}
return text.Substring(0, pos) + text.Substring(pos + search.Length);
}
}
}