Skip to content

Commit

Permalink
Fix the API prefix overly trimmed (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinyoo authored Nov 4, 2021
1 parent 4ab63c2 commit 142b7f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ISwaggerUI AddServer(IHttpRequestDataObject req, string routePrefix, IOpe
{
this._baseUrl = baseUrl;

absolutePath = new Uri(this._baseUrl).AbsolutePath.Trim('/');
absolutePath = new Uri(this._baseUrl).AbsolutePath.TrimEnd('/');
this._swaggerUiApiPrefix = absolutePath;

return this;
Expand All @@ -89,7 +89,7 @@ public ISwaggerUI AddServer(IHttpRequestDataObject req, string routePrefix, IOpe

this._baseUrl = servers.First().Url;

absolutePath = new Uri(this._baseUrl).AbsolutePath.Trim('/');
absolutePath = new Uri(this._baseUrl).AbsolutePath.TrimEnd('/');
this._swaggerUiApiPrefix = absolutePath;

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ public void Given_Options_When_AddServer_Invoked_Then_It_Should_Return_BaseUrl(s
}

[DataTestMethod]
[DataRow("http", "localhost", "api", "api")]
[DataRow("https", "localhost", "api/", "api")]
[DataRow("http", "localhost", "api/prod", "api/prod")]
[DataRow("https", "localhost", "api/prod/", "api/prod")]
[DataRow("http", "localhost", "api", "/api")]
[DataRow("https", "localhost", "api/", "/api")]
[DataRow("http", "localhost", "api/prod", "/api/prod")]
[DataRow("https", "localhost", "api/prod/", "/api/prod")]
public void Given_NullOptions_When_AddServer_Invoked_Then_It_Should_Return_SwaggerUIApiPrefix(string scheme, string host, string routePrefix, string expected)
{
var req = new Mock<IHttpRequestDataObject>();
Expand Down

0 comments on commit 142b7f8

Please sign in to comment.