summaryrefslogtreecommitdiff
path: root/identity/identity.go
diff options
context:
space:
mode:
Diffstat (limited to 'identity/identity.go')
-rw-r--r--identity/identity.go30
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
+
+}