Fix theme manager incorrectly applying default theme if rootPath is specified

This commit is contained in:
nicolas.dorier 2018-04-29 20:48:17 +09:00
parent f0145142a4
commit 7c0b26174f
2 changed files with 14 additions and 2 deletions

View file

@ -135,6 +135,16 @@ namespace BTCPayServer
request.PathBase.ToUriComponent());
}
public static string GetAbsoluteUri(this HttpRequest request, string redirectUrl)
{
bool isRelative = redirectUrl.Length > 0 && redirectUrl[0] == '/';
if (!isRelative)
isRelative = new Uri(redirectUrl, UriKind.RelativeOrAbsolute).IsAbsoluteUri;
if (!isRelative)
return redirectUrl;
return request.GetAbsoluteRoot() + redirectUrl;
}
public static IServiceCollection ConfigureBTCPayServer(this IServiceCollection services, IConfiguration conf)
{
services.Configure<BTCPayServerOptions>(o =>
@ -165,6 +175,7 @@ namespace BTCPayServer
obj is bool b && b;
}
public static StoreData GetStoreData(this HttpContext ctx)
{
return ctx.Items.TryGet("BTCPAY.STOREDATA") as StoreData;

View file

@ -4,6 +4,7 @@
@inject BTCPayServer.Services.BTCPayServerEnvironment env
@inject BTCPayServer.HostedServices.NBXplorerDashboard dashboard
@inject BTCPayServer.HostedServices.CssThemeManager themeManager
@addTagHelper *, Meziantou.AspNetCore.BundleTagHelpers
<!DOCTYPE html>
@ -18,8 +19,8 @@
<title>BTCPay Server</title>
@* CSS *@
<link href="@themeManager.BootstrapUri" rel="stylesheet" />
<link href="@themeManager.CreativeStartUri" rel="stylesheet" />
<link href="@this.Context.Request.GetAbsoluteUri(themeManager.BootstrapUri)" rel="stylesheet" />
<link href="@this.Context.Request.GetAbsoluteUri(themeManager.CreativeStartUri)" rel="stylesheet" />
<bundle name="wwwroot/bundles/main-bundle.min.css" />