Skip to main content

parse_git_remote_url

Function parse_git_remote_url 

Source
pub fn parse_git_remote_url(url: &str) -> Option<GitRemoteUrl>
Expand description

Parse a git remote URL into a host/path pair, accepting the four shapes git itself accepts:

  • git@<host>:<path> (SCP-style; <path> carries the slashes)
  • ssh://[userinfo@]<host>[:<port>]/<path>
  • https://[userinfo@]<host>[:<port>]/<path>
  • http://[userinfo@]<host>[:<port>]/<path>

Userinfo (user@, user:pass@, …) is stripped, ports are stripped from host, surrounding slashes and a single trailing .git are trimmed from path. Returns None for unknown schemes, empty hosts, or empty paths.