mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-10 06:54:12 +00:00
Remove trailing /
This commit is contained in:
parent
7f5fcf882e
commit
e9ea53eb45
1 changed files with 13 additions and 8 deletions
|
@ -335,13 +335,18 @@ pub fn build_url_str_without_scheme(url_str: &str) -> LemmyResult<String> {
|
||||||
.set_scheme("http")
|
.set_scheme("http")
|
||||||
.map_err(|_| LemmyErrorType::InvalidUrl)?;
|
.map_err(|_| LemmyErrorType::InvalidUrl)?;
|
||||||
|
|
||||||
Ok(
|
let mut out = url
|
||||||
url
|
.to_string()
|
||||||
.to_string()
|
.get(7..)
|
||||||
.get(7..)
|
.ok_or(LemmyErrorType::InvalidUrl)?
|
||||||
.ok_or(LemmyErrorType::InvalidUrl)?
|
.to_string();
|
||||||
.to_string(),
|
|
||||||
)
|
// Remove trailing / if necessary
|
||||||
|
if out.ends_with('/') {
|
||||||
|
out.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -628,7 +633,7 @@ mod tests {
|
||||||
])
|
])
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
&vec![
|
&vec![
|
||||||
"example.com/".to_string(),
|
"example.com".to_string(),
|
||||||
"example.com/test?q=test2&q2=test3#test4".to_string()
|
"example.com/test?q=test2&q2=test3#test4".to_string()
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue