18 lines
597 B
Go
18 lines
597 B
Go
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
|||
|
|
// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
||
|
|
|
||
|
|
// Package fediverse validates the fediverse handle that posts, users and
|
||
|
|
// the site configuration carry. It is a leaf so that the configuration
|
||
|
|
// and the domain object can share one rule without either importing the
|
||
|
|
// other.
|
||
|
|
package fediverse
|
||
|
|
|
||
|
|
import "regexp"
|
||
|
|
|
||
|
|
var handleRe = regexp.MustCompile(`\A@[^@\s]+@[^@\s]+\z`)
|
||
|
|
|
||
|
|
// Valid reports whether handle looks like @user@host.
|
||
|
|
func Valid(handle string) bool {
|
||
|
|
return handleRe.MatchString(handle)
|
||
|
|
}
|