mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 22:11:48 +01:00
Fix: Many SVG assets were not showing properly if rootpath is used
This commit is contained in:
parent
fb1fcbe0b9
commit
26bcdbc766
1 changed files with 22 additions and 0 deletions
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue