// MatchEntries returns a Userinfo when the normalized v is found in entries.
MatchEntries returns a Userinfo when the normalized v is found in entries.
// MatchEntries returns a Userinfo when the normalized v is found in entries .
func MatchEntries(v *dburl.URL, entries []Entry) (*url.Userinfo, error) {
	var username string
	if v.User != nil {
		username = v.User.Username()
		if _, ok := v.User.Password(); ok {
			return nil, nil
		}
	}
	n := strings.SplitN(v.Normalize(":", "", 3), ":", 6)
	if len(n) < 3 {
		return nil, ErrUnableToNormalizeURL
	}
	m := NewEntry(n)
	for _, entry := range entries {
		if entry.Equals(m) {
			u := entry.Username
			if entry.Username == "*" {
				u = username
			}
			return url.UserPassword(u, entry.Password), nil
		}
	}
	return nil, nil
}
func MatchEntries ( v * dburl . URL , entries [ ] Entry ) ( * url . Userinfo , error ) { var username string if v . User != nil { username = v . User . Username ( ) if _ , ok := v . User . Password ( ) ; ok { return nil , nil } } n := strings . SplitN ( v . Normalize ( " " , " " , 3 ) , " " , 6 ) if len ( n ) < 3 { return nil , ErrUnableToNormalizeURL } m := NewEntry ( n ) for _ , entry := range entries { if entry . Equals ( m ) { u := entry . Username if entry . Username == " " { u = username } return url . UserPassword ( u , entry . Password ) , nil } } return nil , nil }
MatchEntries returns a Userinfo when the normalized v is found in entries.
MatchEntries returns a Userinfo when the normalized v is found in entries .
// check if v already has password defined ... // find matching entry