2024-09-14 10:13:32 -04:00
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
public class UrlEncodingMiddleware
|
|
|
|
|
{
|
|
|
|
|
private readonly RequestDelegate _next;
|
|
|
|
|
|
|
|
|
|
public UrlEncodingMiddleware(RequestDelegate next)
|
|
|
|
|
{
|
|
|
|
|
_next = next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task InvokeAsync(HttpContext context)
|
|
|
|
|
{
|
2024-09-14 11:14:40 -04:00
|
|
|
if (context.Request.Path.Value != null && context.Request.Path.Value.StartsWith("/api", StringComparison.OrdinalIgnoreCase))
|
2024-09-14 10:13:32 -04:00
|
|
|
{
|
|
|
|
|
if (context.Request.Path.Value.Contains("."))
|
|
|
|
|
{
|
|
|
|
|
var newPath = context.Request.Path.Value.Replace(".", "%2E");
|
|
|
|
|
context.Request.Path = new PathString(newPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await _next(context);
|
|
|
|
|
}
|
|
|
|
|
}
|