| @@ -48,17 +48,22 @@ impl RepositoryUrl { · 47 unmodified lines |
| 48 | self.inner.host.as_ref().map(|h| h == "github.com").unwrap_or(false) | 48 | self.inner.host.as_ref().map(|h| h == "github.com").unwrap_or(false) |
| 49 | } | 49 | } |
| 50 | | 50 | |
| | 51 | fn cleaned_path(&self) -> String { |
| | 52 | let path = self.inner.path.to_str_lossy().into_owned(); |
| | 53 | path.strip_suffix(".git").map(ToOwned::to_owned).unwrap_or(path) |
| | 54 | } |
| | 55 | |
| 51 | pub fn github_https(&self) -> Option<String> { | 56 | pub fn github_https(&self) -> Option<String> { |
| 52 | match &self.inner.host { | 57 | match &self.inner.host { |
| 53 | Some(host) if host == "github.com" => match self.inner.scheme { | 58 | Some(host) if host == "github.com" => match self.inner.scheme { |
| 54 | Scheme::Http | Scheme::Https | Scheme::Git => { | 59 | Scheme::Http | Scheme::Https | Scheme::Git => { |
| 55 | format!("https://github.com{}", self.inner.path.to_str_lossy()).into() | 60 | format!("https://github.com{}", self.cleaned_path()).into() |
| 56 | } | 61 | } |
| 57 | Scheme::Ssh => self | 62 | Scheme::Ssh => self |
| 58 | .inner | 63 | .inner |
| 59 | .user | 64 | .user |
| 60 | .as_ref() | 65 | .as_ref() |
| 61 | .map(|user| format!("https://github.com{}/{}", user, self.inner.path.to_str_lossy())), | 66 | .map(|user| format!("https://github.com{}/{}", user, self.cleaned_path())), |
| 62 | Scheme::Radicle | Scheme::File => None, | 67 | Scheme::Radicle | Scheme::File => None, |
| 63 | }, | 68 | }, |
| 64 | None | Some(_) => None, | 69 | None | Some(_) => None, |