Settings: Tweaks for Catalyst

This commit is contained in:
James Magahern
2021-12-16 16:32:47 -08:00
parent d5ed7f09da
commit 026306b6df
2 changed files with 21 additions and 2 deletions

View File

@@ -68,7 +68,10 @@ class Settings
public var redirectRules: [String: String] = [:]
func redirectRule(for url: URL) -> URL? {
if var components = URLComponents(url: url, resolvingAgainstBaseURL: false), let host = url.host {
if var components = URLComponents(url: url, resolvingAgainstBaseURL: false), var host = url.host {
// Remove "www." if necessary.
host = host.replacingOccurrences(of: "www.", with: "")
if let alternateHost = redirectRules[host] {
components.host = alternateHost
return components.url