1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: include missing mail headers (resolve #472)

This commit is contained in:
Ferdinand Mütsch
2023-03-06 20:31:31 +01:00
parent ce077f2efc
commit fde45a5138
3 changed files with 42 additions and 6 deletions

View File

@@ -1,6 +1,9 @@
package models
import "regexp"
import (
"regexp"
"strings"
)
const (
MailPattern = "[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+"
@@ -36,6 +39,14 @@ func (m MailAddress) Raw() string {
return ""
}
func (m MailAddress) Domain() string {
split := strings.Split(m.Raw(), "@")
if len(split) != 2 {
return ""
}
return split[1]
}
func (m MailAddress) Valid() bool {
return emailAddrRegex.Match([]byte(m))
}