pub fn url_from_string(base_url: &Url, string: Option<&str>) -> Result<Url>
Expand description

Accept an optional string (URL or filename) and from it create an absolute path URL with correct scheme. This allows specifying of full URL (http, file etc) as well as file paths relative to the working directory.

Depending on the parameter passed in:

  • None –> Return the Current Working Directory (CWD)
  • Some(absolute path) –> Return the absolute path passed in
  • Some(relative path) –> Join the CWD with the relative path and return the resulting absolute path.

Returns a full URL with appropriate scheme (depending on the original scheme passed in), and an absolute path.