fix: decode encoded mini customer headers
All checks were successful
Build and Deploy MiniApi / build-and-deploy (push) Successful in 16s
All checks were successful
Build and Deploy MiniApi / build-and-deploy (push) Successful in 16s
This commit is contained in:
@@ -82,6 +82,34 @@ public sealed class OrdersController(IMiniAppService miniAppService, ITenantProv
|
|||||||
|
|
||||||
private string ResolveCustomerName()
|
private string ResolveCustomerName()
|
||||||
{
|
{
|
||||||
return Request.Headers.TryGetValue("X-Mini-Customer-Name", out var name) ? name.FirstOrDefault()?.Trim() ?? string.Empty : string.Empty;
|
if (!Request.Headers.TryGetValue("X-Mini-Customer-Name", out var name))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DecodeHeaderValue(name.FirstOrDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string DecodeHeaderValue(string? value)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
var trimmed = value.Trim();
|
||||||
|
if (!trimmed.Contains('%'))
|
||||||
|
{
|
||||||
|
return trimmed;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Uri.UnescapeDataString(trimmed);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return trimmed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user