Skip to content

Commit

Permalink
fix(lib): Handle ~/ in endpoint routes
Browse files Browse the repository at this point in the history
Fixes #76
  • Loading branch information
PerfectlyNormal committed Sep 18, 2024
1 parent 18c74de commit c6a994d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Fixed

- Don't blindly append controller prefix to API client URLs (#76)

## [0.12.5] - 2024-09-18

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions TypeContractor/TypeScript/ApiClientWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public string Write(ApiClient apiClient, IEnumerable<OutputType> allTypes, TypeS
foreach (var endpoint in apiClient.Endpoints)
{
Logger.Log.Instance.LogDebug($" Processing endpoint {endpoint.Name}");
var url = !string.IsNullOrWhiteSpace(apiClient.Prefix) && !endpoint.Route.StartsWith('/')
var url = !string.IsNullOrWhiteSpace(apiClient.Prefix) && !endpoint.Route.StartsWith('/') && !endpoint.Route.StartsWith("~/", StringComparison.Ordinal)
? $"{apiClient.Prefix}/{endpoint.Route}"
: endpoint.Route;
: endpoint.Route.Replace("~/", string.Empty);
if (!_httpMethods.TryGetValue(endpoint.Method, out var method))
throw new NotImplementedException($"No mapping exists for {endpoint.Method}");

Expand Down

0 comments on commit c6a994d

Please sign in to comment.