mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-02 12:54:22 +01:00
Fix: Many SVG assets were not showing properly if rootpath is used
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Configuration;
|
||||
using BTCPayServer.Security;
|
||||
using BTCPayServer.Services;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
@@ -141,4 +142,25 @@ namespace BTCPayServer.TagHelpers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure that <svg><use href=/ are correctly working if rootpath is present
|
||||
[HtmlTargetElement("use", Attributes = "href")]
|
||||
public class SVGUse : TagHelper
|
||||
{
|
||||
private string _RootPath;
|
||||
|
||||
public SVGUse(BTCPayServerOptions opts)
|
||||
{
|
||||
_RootPath = opts.RootPath;
|
||||
}
|
||||
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_RootPath) || _RootPath == "/")
|
||||
return;
|
||||
var attr = output.Attributes["href"];
|
||||
if (!attr.Value.ToString().StartsWith("/", StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
output.Attributes.SetAttribute("href", $"{_RootPath}{attr.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user