feat(sub): refine Happ routing presets, serverDescription escaping, and auto-detect placement (#6488)

* feat(sub): refine Happ routing presets, serverDescription escaping, and auto-detect placement

* fix(sub): address PR review findings on routing parity, agent regex, and i18n
This commit is contained in:
Pejman Yousefi
2026-09-13 14:23:57 +03:30
committed by GitHub
parent c7518c4038
commit cba8f0672f
10 changed files with 306 additions and 166 deletions
+12 -2
View File
@@ -2271,8 +2271,18 @@ func appendQueryAndFragment(link string, params map[string]string, fragment, sec
if fragment != "" {
sb.WriteByte('#')
// Match the frontend's encodeURIComponent(remark): spaces become %20.
sb.WriteString(strings.ReplaceAll(url.QueryEscape(fragment), "+", "%20"))
if before, after, ok := strings.Cut(fragment, "?serverDescription="); ok {
if _, err := base64.StdEncoding.DecodeString(after); err == nil && len(after) > 0 && !strings.ContainsAny(after, " \r\n\t#&") {
sb.WriteString(strings.ReplaceAll(url.QueryEscape(before), "+", "%20"))
sb.WriteString("?serverDescription=")
sb.WriteString(after)
} else {
sb.WriteString(strings.ReplaceAll(url.QueryEscape(fragment), "+", "%20"))
}
} else {
// Match the frontend's encodeURIComponent(remark): spaces become %20.
sb.WriteString(strings.ReplaceAll(url.QueryEscape(fragment), "+", "%20"))
}
}
return sb.String()
}