diff options
| author | ewy <ewy0@protonmail.com> | 2026-04-14 16:37:17 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-04-14 16:37:17 +0200 |
| commit | 45a297a8e526094e8fce6e2c5c0fd89b381d1765 (patch) | |
| tree | 852ebc3a0112c94dc9726d0b27ab057bf6383660 /identity/identity.go | |
i have to commit at some point!
Diffstat (limited to 'identity/identity.go')
| -rw-r--r-- | identity/identity.go | 30 |
1 files changed, 30 insertions, 0 deletions
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 + +} |
