Skip to content

Commit d2671af

Browse files
committed
Fix compare MapPath
1 parent 0fd1c1e commit d2671af

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Prometheus.Client.MetricServer/MetricServer.HttpListener.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public MetricServer(string host, int port, string mapPath, ICollectorRegistry re
8989
if (!mapPath.StartsWith("/"))
9090
throw new ArgumentException($"mapPath '{mapPath}' should start with '/'");
9191

92-
_mapPath = mapPath.TrimEnd('/');
92+
_mapPath = mapPath.EndsWith("/") ? mapPath : mapPath + "/";
9393
_httpListener.Prefixes.Add($"http{(useHttps ? "s" : "")}://{host}:{port}/");
9494
}
9595

@@ -131,7 +131,9 @@ private void StartListen()
131131
var request = context.Request;
132132
var response = context.Response;
133133

134-
if (request.RawUrl.TrimEnd('/') == _mapPath)
134+
var rawUrl = request.RawUrl.EndsWith("/") ? request.RawUrl : request.RawUrl + "/";
135+
136+
if (rawUrl == _mapPath)
135137
{
136138
response.StatusCode = 200;
137139
response.ContentType = Defaults.ContentType;

src/Prometheus.Client.MetricServer/Prometheus.Client.MetricServer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Description>MetricServer for the Prometheus.Client</Description>
44
<Copyright>2018 © Sergey Kuznetsov</Copyright>
55
<AssemblyTitle>Prometheus.Client.MetricServer</AssemblyTitle>
6-
<VersionPrefix>2.0.1</VersionPrefix>
6+
<VersionPrefix>2.0.2</VersionPrefix>
77
<Authors>Sergey Kuznetsov</Authors>
88
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.3;netstandard2.0</TargetFrameworks>
99
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net45;netstandard1.3;netstandard2.0</TargetFrameworks>

0 commit comments

Comments
 (0)