fix(messages): sync recognize configured app link entities
This commit is contained in:
parent
35d3908660
commit
c9371c6048
12 changed files with 327 additions and 72 deletions
|
|
@ -135,6 +135,24 @@ func (b AppLinkBuilder) BuildUsername(username string, query url.Values) string
|
|||
return b.Build("resolve", query)
|
||||
}
|
||||
|
||||
// AcceptsEntityURL reports whether a raw custom-scheme URL belongs to this
|
||||
// server's configured app-link namespace. The legacy route-as-host scheme is
|
||||
// accepted for rollout compatibility; a distinct host-based scheme is limited
|
||||
// to the exact configured host so arbitrary same-scheme links aren't promoted
|
||||
// to clickable message entities by the server.
|
||||
func (b AppLinkBuilder) AcceptsEntityURL(raw string) bool {
|
||||
parsed, err := url.Parse(raw)
|
||||
if err != nil || parsed.Opaque != "" || parsed.User != nil || parsed.Hostname() == "" || parsed.Port() != "" {
|
||||
return false
|
||||
}
|
||||
if strings.EqualFold(parsed.Scheme, b.legacyScheme) {
|
||||
return true
|
||||
}
|
||||
return b.baseHost != "" &&
|
||||
strings.EqualFold(parsed.Scheme, b.baseScheme) &&
|
||||
strings.EqualFold(parsed.Host, b.baseHost)
|
||||
}
|
||||
|
||||
// MatchesRoute accepts the exact configured host-path form and the retained
|
||||
// legacy route-as-host form. Query validation remains the caller's concern.
|
||||
func (b AppLinkBuilder) MatchesRoute(parsed *url.URL, route string) bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue