pub fn canonicalize_repo_url(repo: &str, host: &str) -> String
Expand description
Canonicalize a repository URL to the form https://{host}/{repo}
§Arguments
repo
- The repository URL e.g.user1/user1-repo
host
- The host for the repository e.g.github.com
§Example
let repo = "bob/bobbys-repo";
let canonicalized = canonicalize_repo_url(repo, "github.com");
assert_eq!(canonicalized, "https://github.com/bob/bobbys-repo");
// If the host is already in the URL, only the protocol is added
let repo = "github.com/lisa/lisas-repo";
let canonicalized = canonicalize_repo_url(repo, "github.com");
assert_eq!(canonicalized, "https://github.com/lisa/lisas-repo");
// If the URL is already in the canonical form, it is returned as is
let repo = "https://gitlab.com/foo-org/foo-repo";
let canonicalized = canonicalize_repo_url(repo, "gitlab.com");
assert_eq!(canonicalized, repo);