mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 07:28:45 -07:00
Fix notification URLs in HTTP deployments
Fixes #19 by making the December server advertise notification and service URLs with the configured deployment scheme.
This commit is contained in:
@@ -11,8 +11,28 @@ namespace DorkNet.Server.Services;
|
||||
public sealed class DomainConfig
|
||||
{
|
||||
public string Apex { get; }
|
||||
public DomainConfig(string apex) { Apex = apex; }
|
||||
public string Scheme { get; }
|
||||
|
||||
public DomainConfig(string apex, string scheme = "https")
|
||||
{
|
||||
Apex = apex;
|
||||
Scheme = NormalizeScheme(scheme);
|
||||
}
|
||||
|
||||
public string Sub(string prefix) => $"{prefix}.{Apex}";
|
||||
public string Url(string prefix, string path = "")
|
||||
{
|
||||
var host = string.IsNullOrEmpty(prefix) ? Apex : Sub(prefix);
|
||||
if (string.IsNullOrEmpty(path)) return $"{Scheme}://{host}";
|
||||
return $"{Scheme}://{host}{(path.StartsWith('/') ? path : "/" + path)}";
|
||||
}
|
||||
|
||||
public static bool MatchesSubdomain(string host, string prefix)
|
||||
=> host.StartsWith(prefix + ".", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private static string NormalizeScheme(string? value)
|
||||
{
|
||||
var scheme = string.IsNullOrWhiteSpace(value) ? "https" : value.Trim().TrimEnd(':', '/', '\\').ToLowerInvariant();
|
||||
return scheme is "http" or "https" ? scheme : "https";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user