Release 2.7.3.3: dark theme and Amnezia vpn:// import fixes.

This commit is contained in:
M4
2026-07-29 19:49:48 +03:00
parent 041cbb1250
commit 64c097d1e7
23 changed files with 401 additions and 69 deletions
+20
View File
@@ -4,6 +4,7 @@ import "strings"
// DetectProtocol infers protocol from a share/proxy URI or config body.
func DetectProtocol(raw string) Protocol {
raw = stripShareNoise(raw)
lower := strings.ToLower(strings.TrimSpace(raw))
switch {
case strings.HasPrefix(lower, "hysteria2://"), strings.HasPrefix(lower, "hy2://"):
@@ -29,3 +30,22 @@ func DetectProtocol(raw string) Protocol {
return ""
}
}
func stripShareNoise(raw string) string {
raw = strings.TrimPrefix(raw, "\ufeff")
var b strings.Builder
for _, r := range raw {
switch r {
case '\u200b', '\u200c', '\u200d', '\u2060', '\ufeff',
'\u2066', '\u2067', '\u2068', '\u2069',
'\u200e', '\u200f',
'\u202a', '\u202b', '\u202c', '\u202d', '\u202e':
continue
}
if r < 0x20 && r != '\n' && r != '\r' && r != '\t' {
continue
}
b.WriteRune(r)
}
return strings.TrimSpace(b.String())
}