Skip to content

Commit c6a994d

Browse files
fix(lib): Handle ~/ in endpoint routes
Fixes #76
1 parent 18c74de commit c6a994d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
### Fixed
11+
12+
- Don't blindly append controller prefix to API client URLs (#76)
13+
1014
## [0.12.5] - 2024-09-18
1115

1216
### Fixed

TypeContractor/TypeScript/ApiClientWriter.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public string Write(ApiClient apiClient, IEnumerable<OutputType> allTypes, TypeS
4444
foreach (var endpoint in apiClient.Endpoints)
4545
{
4646
Logger.Log.Instance.LogDebug($" Processing endpoint {endpoint.Name}");
47-
var url = !string.IsNullOrWhiteSpace(apiClient.Prefix) && !endpoint.Route.StartsWith('/')
47+
var url = !string.IsNullOrWhiteSpace(apiClient.Prefix) && !endpoint.Route.StartsWith('/') && !endpoint.Route.StartsWith("~/", StringComparison.Ordinal)
4848
? $"{apiClient.Prefix}/{endpoint.Route}"
49-
: endpoint.Route;
49+
: endpoint.Route.Replace("~/", string.Empty);
5050
if (!_httpMethods.TryGetValue(endpoint.Method, out var method))
5151
throw new NotImplementedException($"No mapping exists for {endpoint.Method}");
5252

0 commit comments

Comments
 (0)