mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-13 22:26:37 +00:00
Fix <Source as Display>::fmt
impl for Source::Sprase
Add `/` to the end of the url if it doesn't have one Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
parent
2d7feab356
commit
8f13d324c4
1 changed files with 10 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
use std::{borrow::Cow, fmt, str::FromStr};
|
||||
use std::{borrow::Cow, fmt::{Self, Write as _}, str::FromStr};
|
||||
|
||||
use binstalk_types::maybe_owned::MaybeOwned;
|
||||
use compact_str::CompactString;
|
||||
|
@ -128,7 +128,15 @@ impl fmt::Display for Source<'_> {
|
|||
Source::Git(url) => write!(f, "git+{url}"),
|
||||
Source::Path(url) => write!(f, "path+{url}"),
|
||||
Source::Registry(url) => write!(f, "registry+{url}"),
|
||||
Source::Sparse(url) => write!(f, "sparse+{url}"),
|
||||
Source::Sparse(url) => {
|
||||
let url = url.as_str();
|
||||
write!(f, "sparse+{url}")?;
|
||||
if (url.ends_with("/")) {
|
||||
Ok(())
|
||||
} else {
|
||||
f.write_char('/')
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue