mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-13 11:35:51 +01:00
Rewrite the condition to show Onion-Location in a more readable way
This commit is contained in:
parent
7d21b39534
commit
0a6ea59254
1 changed files with 8 additions and 3 deletions
|
@ -58,9 +58,14 @@ namespace BTCPayServer.Hosting
|
|||
return;
|
||||
}
|
||||
|
||||
if (!httpContext.Request.IsOnion() && (httpContext.Request.Headers["Accept"].ToString()
|
||||
.StartsWith("text/html", StringComparison.InvariantCulture) && (
|
||||
!httpContext.Request.Query.TryGetValue("view", out var view) || view != "modal")))
|
||||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue