/* * Copyright 2026 Oleg Borodin * * This work is published and licensed under a Creative Commons * Attribution-NonCommercial-NoDerivatives 4.0 International License. * * Distribution of this work is permitted, but commercial use and * modifications are strictly prohibited. */ package accountcmd import ( "net/url" "path" "strings" ) func packUserinfo(resurseuri, username, password string) (string, error) { var err error var res string if !strings.Contains(resurseuri, "://") { resurseuri = "https://" + resurseuri } uri, err := url.Parse(resurseuri) if err != nil { return res, err } uri.Path = path.Clean(uri.Path) if username != "" && password != "" { uri.User = url.UserPassword(username, password) } res = uri.String() return res, err }