mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
Merge pull request #29 from rustic-rs/fix-rest-path
REST backend: ensure that url ends with '/' and fix config path
This commit is contained in:
commit
a75cf67c48
@ -15,8 +15,17 @@ pub struct RestBackend {
|
||||
|
||||
impl RestBackend {
|
||||
pub fn new(url: &str) -> Self {
|
||||
let url = if url.ends_with('/') {
|
||||
Url::parse(url).unwrap()
|
||||
} else {
|
||||
// add a trailing '/' if there is none
|
||||
let mut url = url.to_string();
|
||||
url.push('/');
|
||||
Url::parse(&url).unwrap()
|
||||
};
|
||||
|
||||
Self {
|
||||
url: Url::parse(url).unwrap(),
|
||||
url,
|
||||
client: Client::new(),
|
||||
}
|
||||
}
|
||||
@ -49,7 +58,7 @@ impl ReadBackend for RestBackend {
|
||||
return Ok(
|
||||
match self
|
||||
.client
|
||||
.head(self.url.join("/config").unwrap())
|
||||
.head(self.url.join("config").unwrap())
|
||||
.send()
|
||||
.await?
|
||||
.status()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user