mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-15 01:25:00 +03:00
fix(url): keep capitalized mailto: and tel: links as they are (#7052)
EnsureURLScheme matched the mailto: and tel: prefixes case-sensitively, so a support link typed as Mailto: or TEL: (phone keyboards capitalize the first letter) got https:// prepended and opened a broken web page. URL schemes are case-insensitive, and the check now is too.
This commit is contained in:
@@ -16,9 +16,12 @@ func EnsureURLScheme(raw string) string {
|
||||
if trimmed == "" {
|
||||
return ""
|
||||
}
|
||||
// Schemes are case-insensitive (RFC 3986), and phone keyboards often
|
||||
// capitalize the first letter ("Mailto:", "Tel:").
|
||||
lower := strings.ToLower(trimmed)
|
||||
if strings.Contains(trimmed, "://") ||
|
||||
strings.HasPrefix(trimmed, "mailto:") ||
|
||||
strings.HasPrefix(trimmed, "tel:") {
|
||||
strings.HasPrefix(lower, "mailto:") ||
|
||||
strings.HasPrefix(lower, "tel:") {
|
||||
return trimmed
|
||||
}
|
||||
return "https://" + trimmed
|
||||
|
||||
Reference in New Issue
Block a user