Summary

Class:WireMock.Util.UrlUtils
Assembly:WireMock.Net
File(s):C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Util\UrlUtils.cs
Covered lines:15
Uncovered lines:0
Coverable lines:15
Total lines:38
Line coverage:100%
Branch coverage:100%

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
Parse(...)0011
RemoveFirst(...)0011

File(s)

C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Util\UrlUtils.cs

#LineLine coverage
 1using System;
 2using JetBrains.Annotations;
 3using WireMock.Models;
 4#if !USE_ASPNETCORE
 5using Microsoft.Owin;
 6#else
 7using Microsoft.AspNetCore.Http;
 8#endif
 9
 10namespace WireMock.Util
 11{
 12    internal static class UrlUtils
 13    {
 14        public static UrlDetails Parse([NotNull] Uri uri, PathString pathBase)
 5115        {
 5116            if (!pathBase.HasValue)
 4717            {
 4718                return new UrlDetails(uri, uri);
 19            }
 20
 421            var builder = new UriBuilder(uri);
 422            builder.Path = RemoveFirst(builder.Path, pathBase.Value);
 23
 424            return new UrlDetails(uri, builder.Uri);
 5125        }
 26
 27        private static string RemoveFirst(string text, string search)
 428        {
 429            int pos = text.IndexOf(search);
 430            if (pos < 0)
 131            {
 132                return text;
 33            }
 34
 335            return text.Substring(0, pos) + text.Substring(pos + search.Length);
 436        }
 37    }
 38}