File: util_url.go

package info (click to toggle)
golang-github-nicholas-fedor-shoutrrr 0.8.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,332 kB
  • sloc: sh: 61; makefile: 5
file content (15 lines) | stat: -rw-r--r-- 440 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package util

import "net/url"

// URLUserPassword is a replacement/wrapper around url.UserPassword that treats empty string arguments as not specified.
// If no user or password is specified, it returns nil (which serializes in url.URL to "").
func URLUserPassword(user, password string) *url.Userinfo {
	if len(password) > 0 {
		return url.UserPassword(user, password)
	} else if len(user) > 0 {
		return url.User(user)
	}

	return nil
}