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
491 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. if !strings.HasPrefix(str, "acct:") {
  12. err = errors.New("URI is not an account")
  13. return
  14. }
  15. items := strings.Split(str, "@")
  16. a.Name = items[0][5:]
  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. }