mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-06 07:34:26 +01:00
Merge pull request #2180 from btcpayserver/attempt-onion-modal-fix
Do not tell tor browser to redirect if invoice is loaded as a modal
This commit is contained in:
@@ -58,7 +58,14 @@ namespace BTCPayServer.Hosting
|
||||
return;
|
||||
}
|
||||
|
||||
if (!httpContext.Request.IsOnion() && (httpContext.Request.Headers["Accept"].ToString().StartsWith("text/html", StringComparison.InvariantCulture)))
|
||||
var isHtml = httpContext.Request.Headers.TryGetValue("Accept", out var accept)
|
||||
&& accept.ToString().StartsWith("text/html", StringComparison.OrdinalIgnoreCase);
|
||||
var isModal = httpContext.Request.Query.TryGetValue("view", out var view)
|
||||
&& view.ToString().Equals("modal", StringComparison.OrdinalIgnoreCase);
|
||||
if (!string.IsNullOrEmpty(_Env.OnionUrl) &&
|
||||
!httpContext.Request.IsOnion() &&
|
||||
isHtml &&
|
||||
!isModal)
|
||||
{
|
||||
var onionLocation = _Env.OnionUrl + httpContext.Request.GetEncodedPathAndQuery();
|
||||
httpContext.Response.SetHeader("Onion-Location", onionLocation);
|
||||
|
||||
Reference in New Issue
Block a user