Skip to content

Commit 37fe583

Browse files
committed
feat: prepend '/' if MapPath not start with '/'
1 parent cbe7c8d commit 37fe583

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

src/MetricServer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public MetricServer(MetricServerOptions options)
3434
if (options == null)
3535
throw new ArgumentNullException(nameof(options));
3636

37-
if (string.IsNullOrEmpty(options.MapPath) || !options.MapPath.StartsWith("/"))
38-
throw new ArgumentException($"mapPath '{options.MapPath}' should start with '/'");
37+
if (!options.MapPath.StartsWith("/"))
38+
options.MapPath = "/" + options.MapPath;
3939

4040
_options = options;
4141

tests/MetricServerTests.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,6 @@ public async Task MapPath_WithEndSlash()
113113
}
114114
}
115115

116-
[Fact]
117-
public void Wrong_MapPath()
118-
{
119-
Assert.Throws<ArgumentException>(() => new MetricServer(
120-
new MetricServerOptions { Port = _port, MapPath = "temp" }));
121-
}
122-
123116
[Theory]
124117
[InlineData("/metrics")]
125118
[InlineData("/metrics12")]
@@ -306,7 +299,6 @@ public async Task Add_Encoding()
306299
}
307300
}
308301

309-
310302
[Fact]
311303
public void Null_Options_Throws_ArgumentNullException()
312304
{

0 commit comments

Comments
 (0)