From 45a297a8e526094e8fce6e2c5c0fd89b381d1765 Mon Sep 17 00:00:00 2001 From: ewy Date: Tue, 14 Apr 2026 16:37:17 +0200 Subject: i have to commit at some point! --- identity/identity.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 identity/identity.go (limited to 'identity') diff --git a/identity/identity.go b/identity/identity.go new file mode 100644 index 0000000..ee4dfea --- /dev/null +++ b/identity/identity.go @@ -0,0 +1,30 @@ +package identity + +import "strings" + +type Identity struct { + Full string + Reduced string +} + +func (i Identity) Is(input string) bool { + return Reduce(input) == i.Reduced +} + +func New(input string) Identity { + return Identity{ + Full: input, + Reduced: Reduce(input), + } + +} + +func Reduce(input string) string { + reduced := input + if !strings.HasPrefix(reduced, ".") { + reduced = strings.Split(reduced, ".")[0] + } + reduced = strings.ToLower(reduced) + return reduced + +} -- cgit v1.3