| 1 | package utilscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util`/ |
| 2 | |
| 3 | import "net/urlscip-go gomod github.com/golang/go/src . `net/url`/" |
| 4 | |
| 5 | // URLUserPassword creates a url.Userinfo from user and password strings. |
| 6 | // |
| 7 | // Unlike url.UserPassword, this function treats empty strings as "not specified": |
| 8 | // - If password is non-empty, returns url.UserPassword(user, password). |
| 9 | // - If password is empty but user is non-empty, returns url.User(user). |
| 10 | // - If both are empty, returns nil (which serializes to "" in url.URL). |
| 11 | // |
| 12 | // Parameters: |
| 13 | // - user: The username, or empty string if no authentication. |
| 14 | // - password: The password, or empty string if no password. |
| 15 | // |
| 16 | // Returns: |
| 17 | // - A *url.Userinfo with the appropriate authentication info, or nil if neither user nor password is provided. |
| 18 | func URLUserPasswordscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util`/URLUserPassword().(user, password string) *urlscip-go gomod github.com/golang/go/src . `net/url`/.Userinfoscip-go gomod github.com/golang/go/src . `net/url`/Userinfo# { |
| 19 | if password != "" { |
| 20 | return urlscip-go gomod github.com/golang/go/src . `net/url`/.UserPasswordscip-go gomod github.com/golang/go/src . `net/url`/UserPassword().(user, password) |
| 21 | } else if user != "" { |
| 22 | return urlscip-go gomod github.com/golang/go/src . `net/url`/.Userscip-go gomod github.com/golang/go/src . `net/url`/User().(user) |
| 23 | } |
| 24 | |
| 25 | return nil |
| 26 | } |