xmpp/structs.go
changeset 171 2f6ae54a2bd1
parent 163 3f891f7fe817
child 172 36a42bc073f0
equal deleted inserted replaced
170:d496de556c9a 171:2f6ae54a2bd1
   160 		result = result + "/" + jid.Resource
   160 		result = result + "/" + jid.Resource
   161 	}
   161 	}
   162 	return result
   162 	return result
   163 }
   163 }
   164 
   164 
   165 // Set implements flag.Value. It returns true if it successfully
   165 // Set implements flag.Value.
   166 // parses the string.
       
   167 func (jid *JID) Set(val string) error {
   166 func (jid *JID) Set(val string) error {
   168 	r := regexp.MustCompile("^(([^@/]+)@)?([^@/]+)(/([^@/]+))?$")
   167 	r := regexp.MustCompile("^(([^@/]+)@)?([^@/]+)(/([^@/]+))?$")
   169 	parts := r.FindStringSubmatch(val)
   168 	parts := r.FindStringSubmatch(val)
   170 	if parts == nil {
   169 	if parts == nil {
   171 		return fmt.Errorf("%s doesn't match user@domain/resource", val)
   170 		return fmt.Errorf("%s doesn't match user@domain/resource", val)