yavsc/src/Yavsc.Server/Helpers/HtmlHelpers.cs

21 lines
681 B
C#
Raw Normal View History

2023-03-19 17:57:55 +00:00
using Microsoft.AspNetCore.Html;
2025-02-14 00:20:35 +00:00
using Microsoft.AspNetCore.Http;
2017-02-12 03:53:33 +01:00
using Yavsc.Models.Drawing;
namespace Yavsc.Helpers
{
public static class HtmlHelpers
{
public static HtmlString Color(this Color c)
{
2023-04-07 21:08:47 +01:00
if (c == null) return new HtmlString("#000");
return new HtmlString(String.Format("#{0:X2}{1:X2}{2:X2}", c.Red, c.Green, c.Blue));
2017-02-12 03:53:33 +01:00
}
2017-05-16 02:16:09 +02:00
public static string ToAbsolute(this HttpRequest request, string url)
{
var host = request.Host;
2023-04-07 21:08:47 +01:00
var isSecure = request.Headers[Constants.SshHeaderKey] == "on";
2017-05-16 02:16:09 +02:00
return (isSecure ? "https" : "http") + $"://{host}/{url}";
}
2017-02-12 03:53:33 +01:00
}
2017-05-16 02:16:09 +02:00
}