A golang webfinger server implementation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
468 B

  1. package webfinger
  2. import (
  3. "errors"
  4. "strings"
  5. )
  6. type account struct {
  7. Name string
  8. Hostname string
  9. }
  10. func (a *account) ParseString(str string) (err error) {
  11. items := strings.Split(str, "@")
  12. if strings.HasPrefix(str, "acct:") {
  13. a.Name = items[0][5:]
  14. } else {
  15. a.Name = items[0]
  16. }
  17. if len(items) < 2 {
  18. //TODO: this might not be required
  19. err = errors.New("No domain on account")
  20. return
  21. }
  22. a.Hostname = strings.Split(items[1], "/")[0]
  23. return
  24. }