diff --git a/src/render.rs b/src/render.rs index 6b15705cd8..3bf8ee78ee 100644 --- a/src/render.rs +++ b/src/render.rs @@ -129,6 +129,10 @@ impl<'a> MarkdownRenderer<'a> { if !new_url.ends_with('/') { new_url.push('/'); } + if new_url.ends_with(".git/") { + let offset = new_url.len() - 5; + new_url.drain(offset..offset + 4); + } new_url += "blob/master"; if !url.starts_with('/') { new_url.push('/'); @@ -310,11 +314,12 @@ mod tests { let relative = "[there](there)"; for host in &["github.com", "gitlab.com", "bitbucket.org"] { - for &extra_slash in &[true, false] { + for (&extra_slash, &dot_git) in [true, false].iter().zip(&[true, false]) { let url = format!( - "https://{}/rust-lang/test{}", + "https://{}/rust-lang/test{}{}", host, - if extra_slash { "/" } else { "" } + if dot_git { ".git" } else { "" }, + if extra_slash { "/" } else { "" }, ); let result = markdown_to_html(absolute, Some(&url)).unwrap();