diff options
Diffstat (limited to 'src/copyparty')
| -rw-r--r-- | src/copyparty/mod.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/copyparty/mod.rs b/src/copyparty/mod.rs index 164c9f8..a9f7d01 100644 --- a/src/copyparty/mod.rs +++ b/src/copyparty/mod.rs | |||
| @@ -158,11 +158,7 @@ impl CopypartyClient { | |||
| 158 | /// if a password is configured. Path can be absolute (e.g. `/music/foo.mp3`) | 158 | /// if a password is configured. Path can be absolute (e.g. `/music/foo.mp3`) |
| 159 | /// or relative (`music/foo.mp3`). | 159 | /// or relative (`music/foo.mp3`). |
| 160 | pub fn build_url(&self, path: &str) -> String { | 160 | pub fn build_url(&self, path: &str) -> String { |
| 161 | let prefixed = if path.starts_with('/') { | 161 | let prefixed = self.build_url_no_pw(path); |
| 162 | format!("{}{}", self.base_url, path) | ||
| 163 | } else { | ||
| 164 | format!("{}/{}", self.base_url, path) | ||
| 165 | }; | ||
| 166 | if let Some(pw) = &self.password { | 162 | if let Some(pw) = &self.password { |
| 167 | format!("{prefixed}?pw={pw}") | 163 | format!("{prefixed}?pw={pw}") |
| 168 | } else { | 164 | } else { |
| @@ -170,6 +166,15 @@ impl CopypartyClient { | |||
| 170 | } | 166 | } |
| 171 | } | 167 | } |
| 172 | 168 | ||
| 169 | /// Build full URL without the password parameter. | ||
| 170 | pub fn build_url_no_pw(&self, path: &str) -> String { | ||
| 171 | if path.starts_with('/') { | ||
| 172 | format!("{}{}", self.base_url, path) | ||
| 173 | } else { | ||
| 174 | format!("{}/{}", self.base_url, path) | ||
| 175 | } | ||
| 176 | } | ||
| 177 | |||
| 173 | /// Search copyparty via the jPOST `/?srch` endpoint. | 178 | /// Search copyparty via the jPOST `/?srch` endpoint. |
| 174 | /// | 179 | /// |
| 175 | /// Uses `serde_json::Value` for flexible response parsing (mirroring the Python | 180 | /// Uses `serde_json::Value` for flexible response parsing (mirroring the Python |
