fix: redirect loop infinito em URLs com cultura
O middleware redirecionava /pt-BR/* para /pt-BR/* causando ERR_TOO_MANY_REDIRECTS. Adicionada verificação case-sensitive para evitar redirect quando URL já está na forma canônica. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
ea6eacc6c6
commit
00c5a132ab
@ -12,7 +12,8 @@ namespace QRRapidoApp.Middleware
|
|||||||
{
|
{
|
||||||
{ "pt", "pt-BR" },
|
{ "pt", "pt-BR" },
|
||||||
{ "pt-br", "pt-BR" },
|
{ "pt-br", "pt-BR" },
|
||||||
{ "es", "es-PY" }
|
{ "es", "es-PY" },
|
||||||
|
{ "es-py", "es-PY" }
|
||||||
};
|
};
|
||||||
private const string DefaultCulture = "pt-BR";
|
private const string DefaultCulture = "pt-BR";
|
||||||
|
|
||||||
@ -91,6 +92,12 @@ namespace QRRapidoApp.Middleware
|
|||||||
var firstSegment = segments[0];
|
var firstSegment = segments[0];
|
||||||
if (_cultureAliases.TryGetValue(firstSegment, out var mappedCulture))
|
if (_cultureAliases.TryGetValue(firstSegment, out var mappedCulture))
|
||||||
{
|
{
|
||||||
|
// Don't redirect if already using the canonical culture (case-sensitive check)
|
||||||
|
if (firstSegment == mappedCulture)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var remainingSegments = segments.Length > 1
|
var remainingSegments = segments.Length > 1
|
||||||
? "/" + string.Join('/', segments.Skip(1))
|
? "/" + string.Join('/', segments.Skip(1))
|
||||||
: string.Empty;
|
: string.Empty;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user