diff --git a/src/interactors/github.rs b/src/interactors/github.rs index d97e321..3e90bbd 100644 --- a/src/interactors/github.rs +++ b/src/interactors/github.rs @@ -11,7 +11,7 @@ use ::models::repo::{Repository, RepoPath}; const GITHUB_API_BASE_URI: &'static str = "https://api.github.com"; const GITHUB_USER_CONTENT_BASE_URI: &'static str = "https://raw.githubusercontent.com"; -pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result { +pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result { let path_str: &str = path.as_ref(); Ok(format!("{}/{}/{}/HEAD/{}", GITHUB_USER_CONTENT_BASE_URI, diff --git a/src/interactors/gitlab.rs b/src/interactors/gitlab.rs index 6947563..04f5cd1 100644 --- a/src/interactors/gitlab.rs +++ b/src/interactors/gitlab.rs @@ -1,11 +1,12 @@ use hyper::Uri; use relative_path::RelativePathBuf; +use failure::Error; use ::models::repo::RepoPath; const GITLAB_USER_CONTENT_BASE_URI: &'static str = "https://gitlab.com"; -pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result { +pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result { let path_str: &str = path.as_ref(); // gitlab will return a 308 if the Uri ends with, say, `.../raw/master//Cargo.toml`, so make // sure that last slash isn't doubled @@ -14,10 +15,10 @@ pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result< } else { path_str }; - format!("{}/{}/{}/raw/master/{}", + Ok(format!("{}/{}/{}/raw/master/{}", GITLAB_USER_CONTENT_BASE_URI, repo_path.qual.as_ref(), repo_path.name.as_ref(), slash_path - ).parse::() + ).parse::()?) }